Java == operator. "Invalid assignment operator"
Posted
by Tom
on Stack Overflow
See other posts from Stack Overflow
or by Tom
Published on 2010-04-29T18:19:24Z
Indexed on
2010/04/29
18:27 UTC
Read the original article
Hit count: 379
Hi,
I was trying to write a simple method
boolean validate(MyObject o)
{
return o.getPropertyA() == null && o.getPropertyB()==null;
}
And got a strange error on the == null part. Maybe my Java is rusty after a season in PLSQL.
Consider this:
Integer i = 4;
i ==null; //compile error: Syntax error on token ==. Invalid assignment operator.
Integer i2 = 4;
if (i==null); //No problem
How can this be ? Any explanation ?
Im using jdk160_05.
© Stack Overflow or respective owner