For String
comparison you need to use .equals()
, like e1.equals("")
, or argubly better "".equals(e1)
.
The second form is argubly better as it can never throw a NullPointerException
.
Keep in mind that only primitives int
, etc. should be compared with ==
, everything else should be compared with Object#equals(Object)
.