I am a beginner in java and I want to use a centinel loop to repeat code as many times as the condition is not met. However I can't get it to work. This is my code so far:
import java.io.*;
public class Test
{
public static void main(String args[]) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String password = "Pass";
System.out.print("Enter the password: ");
String input = br.readLine();
while(input != password)
{
System.out.println("Wrong password.\n");
System.out.print("Enter the password: ");
input = br.readLine();
}
}
}
However, every time I put the password it simply doesn't work. Could anybody help me please?