Below is code to find an employee based on user input. I cant get it to find Any name even though I initialise array list with some names as soon as program runs. I type it exactly but it does not find it. What am i doing wrong?
public void findEmployee()
{
Scanner input = new Scanner(System.in); // input from user
System.out.println("Please Enter Employee Name: ");
String name = input.nextLine(); //read input for Name
System.out.println( "Searching for employee.... " + name );
for (Employee a : employeeList)
{
if (a.getName() == name) // found a match
{
System.out.println( "Found Employee " + a.getName() + "\tAddress: " + a.getAddress()+ "\tAge: " + a.getAge() + "\tHolidays Left: " + a.getHolidays()+ "\tSalary:" + a .getSalary());
}
}
{
System.out.println("Not found please check spelling and try again");
}
}