+ 3
If you want to check the age , better use a switch statement
20th Jul 2016, 2:42 PM
Orfeo Terkuci
Orfeo Terkuci - avatar
0
You can use the nested way, such as this: if (age > 18) { //code } else { if (age == 18) { //code } else { if (age < 18) { //code } } } Or you can choose to use multiple if-else statements in such a way that: if (age > 18) { //code } else if (age == 18) { //code } else if (age < 18) { //code } Both options work exactly the same, and are both viable. If you want to be picky, opt for the latter method, idealy. And to answer your question, these if-else statements can be used in conjunction as many times as you like, no limit.
20th Jul 2016, 5:01 PM
Cohen Creber
Cohen Creber - avatar