hi there
i have this class here:
and i have one like that but just for password.public class UsernameArrayHolder { public String[] UsernameArrayHolder() { //need identifier String[] UsernameArray = {"user1","user2","user3"}; //variable til at holde login navn return UsernameArray; } }
when i try to call it in my other class like this:
import java.util.*; public class Login2Darray { public static void main(String [] args){ String[] usernameInfo=UsernameArrayHolder.UsernameArray; // i call the other class int i = 0; Scanner sc=new Scanner(System.in); System.out.println("Username: "); String UsernameInput = sc.next(); System.out.println("Password: "); String PasswordInput = sc.next(); for (i=0; i<UsernameArray.length; i++){ if((UsernameInput.equals(UsernameArray[i]) && PasswordInput.equals(PasswordArray[i]))){ System.out.println("You are logged in"); //skriv i værdi til tekst fil i = UsernameArray.length; } }//end of for loop } }
the problem is it doesn't seem to work. am i calling it right? and if not how am i supposed do?