+ 1

Java question

In java language what is the different between if... Else condition statment and else if condition statment especially in terms of use?

14th Apr 2017, 11:44 AM
Faridi Adidi Sadick
Faridi Adidi Sadick - avatar
5 Answers
+ 5
consider you made a program which will only allow users to log in if they are 18+ what will you do if(age>18){ accessgranted(); }else{ accessdenied(); } it simply means that if age is more than 18 then access granted and if something else(like age=18 or <18) access denied. Now consider making a program which will print different things according to age like if(age>18) { System.out. print("GROWN UP") ;} else if(age<18){ System. out. print("welcome") ;} CONCLUSION: if else statement allows you to define one statement and if somethong else. while if u use else if you can define multiple statements.
14th Apr 2017, 12:09 PM
shobhit
shobhit - avatar
+ 18
if (condition) { if the condition is true, this block of code would execute; } else if(condition) { This block of code will execute if the above condition is false and if this condition is true! } else { This block of code will execute if the above conditions are false! }
14th Apr 2017, 12:02 PM
Dev
Dev - avatar
+ 5
in if - else if confition is true then if part is execute otherwise else part is execute but in else if latter if the condition is not true then else part is execute and in else also condition is check. if(condion) statements.. else if(condition) statements..
14th Apr 2017, 12:04 PM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 4
if conditions must be true, else must be false.
14th Apr 2017, 12:04 PM
Andre van Rensburg
Andre van Rensburg - avatar
0
if else is needed when you just have one statement. If else if is for multiple statement, that's all
14th Apr 2017, 1:39 PM
Elvis Briceño
Elvis Briceño - avatar