Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet32/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   28   29   30   31   32   33   34   35   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

Nested if…else Statement
It is legitimate to home if-else constructs, which  implies  you  can  utilize  one  if  or  else  if
proclamation  inside  an  alternate  if  or  else  if  explanation.  The  syntax  for  using  this
construct Is as follows:
if(condition_1){
//Execute if condition_1 is true
if(condition_2){
//Execute if condition_2 is true
}
}
else if(condition_3){
//Execute if condition_3 is true
}
else
{
//Execute if all conditions are false
}
Sample Implementation:
public class myTest {
public static void main(string args[]){
int i = 1;
if( i >= 1 ){
System.out.println(“The if construct is executing!”);
if(i == 1){
System.out.println(“The nested if construct is executing!”);


}
}
else{
System.out.print(“The else construct is executing!”);
}
}
This would create the accompanying result:
The if construct is executing!
The nested if construct is executing!

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   28   29   30   31   32   33   34   35   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling