如何使用相同的扫描器变量读取字符串的int,double和句子
2022-09-05 00:10:03
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=new String();
int x=sc.nextInt();
double y=sc.nextDouble();
s = sc.next();
System.out.println("String:"+s);
System.out.println("Double: "+y);
System.out.println("Int: "+x);
}
}
它扫描只有一个字恳求给出任何建议...