Java boolean to String using Boolean.toString() and String.valueOf()
Approach: Using Boolean.toString()
Java
public class BooleanToString {public static void main(String[] args) {Boolean boolean1 = true;boolean boolean2 = true;System.out.println(Boolean.toString(boolean1));System.out.println(Boolean.toString(boolean2));}}
Approach: Using String.valueOf()
Java
public class BooleanToString {public static void main(String[] args) {Boolean boolean1 = true;boolean boolean2 = true;System.out.println(String.valueOf(boolean1));System.out.println(String.valueOf(boolean2));}}
No comments:
Post a Comment