I am new to java and practicing java programs. My code is as below:
String i;
String[] people={"Ronald","Donald"};
System.out.println("Whose information do you want?"+Arrays.toString(people));
Scanner s =new Scanner(System.in);
**i=s.nextLine();**
if(i=="Ronald")
{
System.out.println("Ronald is CEO and is in Room No 20");
}
if(i=="Donald")
{
System.out.println("Donald is postman and is in Room No 10");
}
}
}
This is actually a simple program. What I wanted to know is whenever user inputs Ronald, its print statement should be printed in console. But the user should be asked whose information it wants to see. I wanted to know how to take string values from user.
Thank you in advance :)