read ArrayList elements

Posted by Jessy on Stack Overflow See other posts from Stack Overflow or by Jessy
Published on 2010-03-28T20:26:34Z Indexed on 2010/03/28 20:33 UTC
Read the original article Hit count: 317

Filed under:
|
|

Why it print the wrong output?

ArrayList<String> loc = new ArrayList<String>();

This arraylist stored the value of:

[topLeft, topLeft, topLeft, bottomLeft, topLeft, bottomLeft, topLeft, topLeft, Left, topLeft]

the firs index 0 is = topLeft

if(loc.get(1)=="topLeft")
   System.out.println("same")

else {
   System.out.println("not same")
}

This program print the wrong output not same instead of same

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist