I have person class with id , first name and last name I have get and set methods
in main I wrote this

when I try to search for something in array list I always use .equal when I tried .equal without the ! it give me nothing , but when I added the ! it worked

I'm suprised can some one explain why it work this way is there soemthing wrong wiht my .equal

 String lookUp = txtLook.getText();
            String aa = null;        
            for (Person p : myList) {
                aa = p.getlName();
                if (!aa.equals(lookUp)) {
                    txtOutput.append(p + "");
                } else {


4 Years
Discussion Span
Last Post by stultuske

you are giving a pretty vague description.
does p have a value? what is lookUp's value?
if the equals without the ! gives "nothing", it means the values aren't identical.
try and printing out the values of aa and lookUp each time you check that. maybe that 'll give the answer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.