So you have the following:
if(condition1){
block1;
}
if(condition2){
block2;
}else{
block3;
}
To disable/ignore the second if
you can either use an else if
statement:
if(condition1){
block1;
} else if(condition2){
block2;
}else{
block3;
}
Or a return statement after block1
if(condition1){
block1;
return;
}
if(condition2){
block2;
}else{
block3;
}
4
solved The if statement in JAVA