import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
String s = scan.nextLine();
double d = scan.nextDouble();
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
答案 0 :(得分:1)
您的代码已运行,但您应添加一些用户提示:
SharedPreferences
应该注意的是,尝试获取字符串输入时会遇到问题。您需要在import java.util.Scanner;
public class TimeTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input integer:");
int i = scan.nextInt();
System.out.println("Input string:");
String s = scan.nextLine();
System.out.println("Input double:");
double d = scan.nextDouble();
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
String s = scan.nextLine();
来清除输入内容