Because you can't compare String
objects with ==
operator.
In Java, ==
operator compare instances for objects. In your case, they're obviously not equal. So, change your ==
for equals()
instead:
if("<li><a href=".equals(tmp.substring(0, 12)))
but be aware that equals()
can't be invoked on null
references, as it will throw a NullPointerException
. You must check if instance is not null
before invoking it.