Is it possible to implement the commented lines in order to distinguish between an Integer and a String when a user inputs said value into the console? The code works with the rest of my program, but I want the user to be able to input the Employee ID (an int) in addition to name and/or address.
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");
}
Aucun commentaire:
Enregistrer un commentaire