I am coding a little program that prompts the user to enter in a password, if the user enters the incorrect password, then the program will keep prompting the user to enter in the password. Once the user enters in the correct password, then the program exits. I created a do-while loop to keep looping until the correct password is entered, but when the correct password is entered, the program continues to loop and does not exit. The variable value does not seem to reach the while clause of the program. Can someone please show me where I am going wrong? My code is as follows:
import java.util.*;
import javax.swing.*;
public class do_whilePassword
{
public static void main ( String [] args )
{
String choice = "";
do
{
choice = JOptionPane.showInputDialog("Please enter in a password");
}while(choice != "John" );
}
}