+ 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?
3 Réponses
+ 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.