+ 2
If I’m understanding your question correctly, yes, you could do something like this: int n = //no. of usernames String[][] userpass = new String[n][2]; for (int i=0; i<n; i++) { userpass[i][0] = //enter username userpass[i][1] = //enter password } This isn’t an ideal solution, though, for two reasons: 1. Arrays have a fixed size. Never a good choice if you may want to change the number of entries later. 2. Each username/password pair is not inherently linked. They share the same row, which keeps it organized, but you’d have to jump through hoops to, say, retrieve the correct password given a particular username. Instead, it’s more practical to use a class which uses key-value mappings, such as a HashMap: https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html You could create a HashMap<String,String> and store each username/password pair with the method put(user, pass) and retrieve a password using get(user). I’m sure you’ll find use for some of the other methods in the documentation, as well. Hope that helps!
23rd Aug 2018, 2:09 AM
krikkitbot
krikkitbot - avatar