First let me tell you what I want to do. The program should ask for a password and then create array lists for each character of the password. These list will then be added to the overall array list.(mylist) The question is how do I then populate the ArrayLists with String values? When all the Arraylists are populated i want to be able to sort them in Alphabetical order. Code blow.
// Creating ArrayLists
ArrayList<ArrayList<String>> mylist = new ArrayList<ArrayList<String>>();
List<String> mycode = new ArrayList<String>();
char[] test;
String mypassword;
System.out.println("Pleaseinput your passphrase");
// Getting user input (Password)
Scanner in = new Scanner(System.in);
mypassword = in.nextLine();
// Storing password in character array
test= mypassword.toCharArray();
// Beginning for loop to create array lists for each character
// in the password
for (int i = 0; i < mypassword.length(); i++) {
mycode = new ArrayList<String>();
// Here I'm trying to give the created Arraylist (mycode)
// a name or value of the character the for loop is at so I can order it alphabetically later.
mycode.equals(test[i]);
// Adds the array list.
mylist.add((ArrayList<String>) mycode);
}
Thanks in advance for any suggestions on my question.
Aucun commentaire:
Enregistrer un commentaire