Skip to content

Commit 041f873

Browse files
1add.java
Example 1: Convert boolean to string using valueOf()
1 parent 5e049ac commit 041f873

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

1add.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Main {
2+
public static void main(String[] args) {
3+
4+
// create boolean variables
5+
boolean booleanValue1 = true;
6+
boolean booleanValue2 = false;
7+
8+
// convert boolean to string
9+
// using valueOf()
10+
String stringValue1 = String.valueOf(booleanValue1);
11+
String stringValue2 = String.valueOf(booleanValue2);
12+
13+
System.out.println(stringValue1); // true
14+
System.out.println(stringValue2); // true
15+
}
16+
}

0 commit comments

Comments
 (0)