Java comparing two arrays?

I'm trying to get the you are logged in prompt to work, but every time I enter a correct username and password it always says invalid try again Here is the code import java.util.Arrays; import javax.swing.JOptionPane; public class UserLogin { public static void main(String[] args) { // arrays... show more I'm trying to get the you are logged in prompt to work, but every time I enter a correct username and password it always says invalid try again Here is the code


import java.util.Arrays;

import javax.swing.JOptionPane;

public class UserLogin {

public static void main(String[] args) {

// arrays for usernames, passwords, and number of logins

String[] usernames = { "x", "jimmy12", "john05" , "lauren01", "katie90"};
String[] passwords = { "x", "mets7654", "bass1276", "beauty0000", "password2176"};
int[] numlogs = new int[5];





String login = (JOptionPane.showInputDialog("(l)ogin to account\n" + "(q)uit program\n"));

// handles user's choice

while (login.equals("q") == false) {
login = JOptionPane.showInputDialog("Enter username ");
login = JOptionPane.showInputDialog("Enter password ");

if (Arrays.equals(usernames, passwords)) {
JOptionPane.showMessageDialog(null, "you are logged in");
} else {
JOptionPane.showMessageDialog(null, "invaild try again");

} // ends if statement

login = JOptionPane.showInputDialog("(l)ogin to account\n" + "(q)uit program\n");


} // ends while loop


} // ends main



} // ends class
2 answers 2