2 回答
TA贡献1818条经验 获得超8个赞
你的班级名称是Scanner. 您应该将您的类重命名为ScannerTest并作为参数import java.util.Scanner;传递给您的类。System.inScanner
import java.util.Scanner;
public class ScannerTest {
public static void main(String[]args) {
Scanner person = new Scanner(System.in);
System.out.print("Enter age: " );
int age = person.nextInt();
System.out.print("Enter gender male/female: ");
String gender = person.nextLine();
}
}
TA贡献1820条经验 获得超2个赞
首先,您需要更改班级名称。
import java.util.Scanner;
然后在你的班级上方输入然后你需要添加
system.in
为new Scanner(system.in);
我的审判:
package test;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner person = new Scanner(System.in);
System.out.print("Enter age: " );
int age = person.nextInt();
System.out.print("Enter gender male/female: ");
String gender = person.nextLine();
}
}
添加回答
举报