Wednesday, December 25, 2013

[Java] Convert to Boolean

This is an example code that returns boolean equivalent of 'Y' or 'N' to true or false.

public boolean getBooleanEquivalent(String str){
   if (str == null 
       || ("").equalsIgnoreCase(str) 
       || str.equalsIgnoreCase("N"))
   {
      return false;
   }
   else
   {
      return true;
   }

}

No comments:

Post a Comment