0
我的輸入將是提供在Java中使用掃描儀輸入的多行
12
4.0
has to be concatenated with this input
我的預期輸出是
16
8.0
RandomString has to be concatenated with this input
如下
我它試圖做到這一點是代碼
int i = 4;
double d = 4.0;
String s = "RandomString";
Scanner scan = new Scanner(System.in);
int j = scan.nextInt();
double e = scan.nextDouble();
String str = scan.nextLine();
int resInt = i + j; double resDouble = d + e; String resString = s +" "+ str;
System.out.println(resInt);
System.out.println(resDouble);
System.out.println(resString);
scan.close();
這表現有所不同。只要我輸入兩行輸入,它就會給我輸出。不等待我的輸入的第三行。所以現在我的輸出是
12
4.0
16
8.0
RandomString