import javax.swing.JOptionPane;
public class Login{
public static void main(String[] args){
String username = JOptionPane.showInputDialog("What is the desired username?");
String password = JOptionPane.showInputDialog("What is the desired password?");
boolean unlock=false;
while(unlock==false){
String usernameinput = JOptionPane.showInputDialog("What is the username?");
if(username==usernameinput){
String passwordinput = JOptionPane.showInputDialog("What is the password?");
if(passwordinput==password){
System.out.println("access granted");
unlock=true;
}else{
System.out.println("denied");
}
}else{
System.out.println("denied");
}
}
}
}
This code should allow me to input a username and password when prompted then show that access is granted when they are equal but the program seems to not allow it. Am I doing something wrong here?