我遇到了问题,因为当我尝试编译我的代码时,它说该扫描仪无法作为符号找到。
我该怎么做才能解决它?
public class Unit10
{
public static void main( String[] args )
{
scanner input = new scanner(System.in);
int numEmployees;
System.out.println( "How many employees do you wish to enter?" );
numEmployees = input.nextInt();
Employee[] employeeArray = new Employee[numEmployees];
for ( int i = 0; i < numEmployees; i++ )
{
Employee e1 = new Employee();
Name first = new Name();
Name last = new Name();
System.out.println( "Enter the first name of the employee" );
e1.setFirstName( input.nextLine() );
System.out.println( "Enter the last name of the employee" );
e1.setLastName( input.nextLine() );
}
}
}
答案 0 :(得分:1)
Scanner
是一个类,库中的每个类都以大写字母开头:
Scanner input = new Scanner(System.in);
答案 1 :(得分:0)
您是否在程序开头导入了java.util.scanner?
另外,我认为这是“扫描仪”,而不是“扫描仪”
答案 2 :(得分:0)
使用此导入:
import java.util.Scanner;