I'm building a small application (for fun) to basically track employees and products in a java app. I have created the arraylists and the classes but I'm having trouble sorting through them and searching.. Here is what I have tried so far..
I'm trying to search the objects of the arraylist based off of employee name
System.out.println("Enter name of employee to search: \n");
String name = keyboard.nextLine();
Iterator itr = employeeList.iterator();
while (itr.hasNext()) {
Employee test = (Employee) itr.next();
if (test.getFirstName() == name.toString()) {
System.out.println(test.getEmpInfo());
}
}
My dilema is that if I replace the name.toString() with the name in quotes it works, but if I use the keyboard.nextLine() it won't work, any help would be greatly appreciated!