Best approach to converting Boolean object to string in java

后端 未结 7 889
暖寄归人
暖寄归人 2020-12-13 01:51

I am trying to convert boolean to string type...

Boolean b = true;
String str = String.valueOf(b);

or

Boolean b = true;
Str         


        
7条回答
  •  青春惊慌失措
    2020-12-13 02:19

    If this is for the purpose of getting a constant "true" value, rather than "True" or "TRUE", you can use this:

    Boolean.TRUE.toString();
    Boolean.FALSE.toString();
    

提交回复
热议问题