if boolean java

Solutions on MaxInterview for if boolean java by the best coders in the world

showing results for - "if boolean java"
Yusuf
31 Sep 2017
1//FORMAT (Yes you can copy paste this, you lazy bimbo.)
2if (CONDITION) {
3// Do this if CONDITION true
4} else {
5// Do this if CONDITION false
6}
7
8
9// Example
10int x = 3;
11int y = 5;
12
13if (x < y) {
14  System.out.println("True");
15} else {
16  System.out.println("False");
17}
18//Output: True
19
20
21//Another example
22int x = 3;
23int y = 5;
24
25if (x < y) {
26  System.out.println("Y is bigger");
27} else if (x == y) {
28  System.out.println("X and Y are the same");
29} else {
30  System.out.println("X is bigger");
31}
32//Output: Y is bigger
33//Note that when using if right after an else is effectively the same is nesting the if inside that else.
34//Make sure you never do that and use "else if" instead.
35