Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jasmine Grant   on Nov 05 In Java Category.

  
Question Answered By: Marc Anderson   on Nov 05

if ( anything == " ") isn't going to be much use to you
try replacing those sort of if statements with if(isBlank(anything))
where isBlank is defined as below

private boolean isBlank(String str)
{
if(str==null) return  true;
if(str.trim().equals("")) return true;
return false;
}

what you are doing in your code  is comparing the handle of the respective
strings not the content
you could do something like if(" ".equals(anything)) if you only wanted to test
for
the single space character (but I don't think that is what you really want.

Share: