if-else Syntax:
if(<boole an expression>)
<statement_or_block>
else
<statement_or_block>
Example of if-else:-
public class IfTest{
public static void main(String[]args){
int x = (in) (Math.random()*100);
System.out.prinln(x);
if(x>100){
System.out.println(”WHITE”);
}
else{
System.out.println(”BLACK”);
}
}
}
if(<boole an expression>)
<statement_or_block>
else
<statement_or_block>
Example of if-else:-
public class IfTest{
public static void main(String[]args){
int x = (in) (Math.random()*100);
System.out.prinln(x);
if(x>100){
System.out.println(”WHITE”);
}
else{
System.out.println(”BLACK”);
}
}
}