获取您的 Java 服务器
import java.util.Scanner;  // Import the Scanner class

public class MyClass {
  public static void main(String[] args) {
    int x, y, sum;
    Scanner myObj = new Scanner(System.in);  // Create a Scanner object
    System.out.println("Type a number:");
    x = myObj.nextInt(); // Read user input

    System.out.println("Type another number:");
    y = myObj.nextInt(); // Read user input

    sum = x + y;
    System.out.println("Sum is: " + sum); // Output user input
  }
} 

              
输入一个数字

输入另一个数字