Java java.lang Boolean toString(boolean b)
Description Of Boolean: toString(boolean b)
The java.lang.Boolean.toString(boolean b) returns a String object representing this Boolean's value. If this object represents the value true, a string equal to "true" is returned. Otherwise, a string equal to "false" is returned.
Boolean.toString(boolean b) method returns a string representation of this object.
Code Example Java Boolean
public class BooleanExam {
public static void main(String[] args) {
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(null);
String s1 = b1.toString();
String s2 = b2.toString();
String str1 = "String value of boolean object " + b1 + " is " + s1;
String str2 = "String value of boolean object " + b2 + " is " + s2;
// print s1, s2 values
System.out.println(str1);
System.out.println(str2);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น