System.out.println("what is your name? ");
String name = kb.nextLine();
for(int i = 0; i < member2.size(); i++){
     System.out.println(name + " is a member. ");
  System.out.println(name +" is not a member. ");

i did a system.out.println on the member2 arraylist (String arraylist) and it prints out the correct stuff. when comparing whether or not name is equal to an item in the arraylist, it always give me the else statement even if the name is in the list.

for example, member2 contains:

and then i would type in "john", and it gives me "john is not a member."

Edited 6 Years Ago by plasticfood: n/a

It looks to me like your if statement is executed every time you compare, that way if the first string in the ArrayList is not the one you entered it returns ___ is not a member. Try using an intermediate variable like this:

boolean found = false;
for(String s : member2)
        found = true;
    System.out.println(name + " is a member. ");
  System.out.println(name +" is not a member. ");
This question has already been answered. Start a new discussion instead.