开发者

how can i refer to a string array inside and array list

i have an array list that is holding two string arrays.. one dedicated to usernames and another to passwords

    ArrayList<Person> popul = new ArrayList<Person>();
    String[] u = {"Herp","Derp","LOL"};
    String[] p = {"hello123", "qwerty42", "iliketurtles"};

in another class inside the main method i am trying to get the passwords from the popul arrayList to turn into hash.. i have set up a loop to get each password but I do not know how to get only from the password string array and not the username...

for(int x = 0; x < popul.size(); x++开发者_如何学运维){
  popul.get(x);
}

any help is greatly appreciated, thanks


Confusing code, I am assuming you have an arraylist holding 2 String arrays u and p and you want to traverse the passwords array. If that is correct, and if u added u first and p later, your password array can be retrieved by

popul.get(1);

So to traverse the passwords you should be doing

for(String password: popul.get(1))
{
 System.out.println(password);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜