兩個整數用空格隔開?
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("請輸入兩個整數,以空格隔開");
String num = sc.nextLine();
System.out.println(num);
System.out.println("兩個數的和為:" + (Integer.parseInt(num.split(" ")[0]) + Integer.parseInt(num.split(" ")[1])));
sc.close();
}
}