96
Java Convert boolean to String
We can convert boolean to String in java using String.valueOf(boolean) method.
Alternatively, we can use Boolean.toString(boolean) method which also converts boolean into String.
1) String.valueOf()
The String.valueOf() method converts boolean to String. The valueOf() is the static method of String class. The signature of valueOf() method is given below:
Java boolean to String Example using String.valueOf()
Let’s see the simple example of converting boolean to String in java.
Output:
true false
2) Boolean.toString()
The Boolean.toString() method converts boolean to String. The toString() is the static method of Boolean class. The signature of toString() method is given below:
Java boolean to String Example using Boolean.toString()
Let's see the simple code to convert boolean to String in java using Boolean.toString() method.
Output:
true false
Next TopicJava Date to Timestamp