18 Aug Java Program to convert int to boolean without specifying boolean type
Let’s say we have initialized two int variables and want to convert them to boolean. Following are our integers:
1 2 3 4 |
int a = 1; int b = 0 |
Now, we will compare the integers a and b as in the example below:
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class Main { public static void main(String[] args) { int a = 1; int b = 0; if(a == b) { System.out.println(true); } else { System.out.println(false); } } } |
Output
1 2 3 |
false |
No Comments