Again, I seem to find myself in a web of simple but difficult to figure out what the problem is. I have the code below that just keeps getting the user's name and displaying it until the user enter's an empty string. Well, to simulate that, I just hit the keyboard instead of entering any name but for some reasons I am not seeing in my code, the programme just keeps looping. Any help on this?
System.out.println("Enter your name : \n"); Scanner st = new Scanner(System.in); while(st.hasNext()){ System.out.println("Enter your name : \n"); String name = st.nextLine(); System.out.println(name); if(name==" ") break; } System.out.println("you are out of the while loop now!!");