+ 1

How many && condition I can add inside if()

if (age > 18 && money > 500) { System.out.println("Welcome!"); } in this code we just used 2 condition. but if I wanna add 3 or 4 condition, can I write it like this? if(age>18 && money>500 && hight>6) { system.out.println("it work"); } will it work? and can I use same method with OR?

20th Apr 2018, 6:51 PM
RH Tasin
RH Tasin - avatar
3 Answers
+ 3
Yep, it’ll work with both. You can add as many conditions as you like, and you can mix and match AND, OR, and XOR as much as you want.
20th Apr 2018, 7:01 PM
DaemonThread
DaemonThread - avatar