当用户将所述值输入控制台时,是否可以实现注释行以区分Integer和String?代码与我的程序的其余部分一起使用,但我希望用户能够输入除名称和/或地址之外的Employee ID(一个int)。
public void query(){
String newValue;
System.out.println("Please enter the name, address, or employee "
+ "ID you are looking for");
Scanner input = new Scanner(System.in);
//if (Integer.parseInt(input);
//newValue = input.nextInt();
//else
newValue = input.nextLine();
input.close();
if (name.equals(newValue) | address.equals(newValue) )
System.out.println(toString());
else System.out.println("There is no employee with that name, address, or ID");
}