I've been working on some code to try to make sure I understand all of the ways to use ArrayList
s and just some things I've been working on when I compile this code I get three errors for each "girlsNames.get(#)" on the girlsNames variable. I only get errors when I use the .get command and not when I use .add. tried assigning each "girlsNames.get()" to a variable then using that in the main method instead but it still doesn't work... I can't figure out the problem!
import java.util.ArrayList;
class List {
public void babyNames(){
ArrayList<String> girlsNames = new ArrayList<String>(3);
girlsNames.add("Jennifer");
girlsNames.add("Blorjek");
girlsNames.add("Robby");
}
public static void main(String[] args) {
if(args[0] == girlsNames.get(0))
{ System.out.println("Hello guardian of Jennifer");
}
else if(args[0] == girlsNames.get(1))
{ System.out.println("Hello guardian of Blorjek");
}
else if(args[0] == girlsNames.get(2))
{ System.out.println("Hello guardian of Robby");
}
else System.out.println("you may not enter the sanctuary");
}
}