android - How to hide some strings with certain condition? -


i have simple yet problem cannot solve. want program show parentheses when string length greater 1 or when not null. however, condition doesn't work. there problems in code?

string _name = json.getstring("name");  if(_name.length()>3){     _name = "("+_name+")"; }else{  }  map1.put("name", _name); 

i want save string parentheses when json data not null or empty. doesn't seem work. shows parenthesis time empty space between them.

as per requirement, "show parentheses when string length greater 1 or when not null".

string _name = json.getstring("name");  put below condition.  // check null of string here. can check length here based on condition. if(_name != null && _name != "" && !_name.equalsignorecase("") && _name.length() > 1 ) {    _name = "("+_name+")"; } else {    //other stuff here } 

Popular posts from this blog