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