Powered by Blogger.
Showing posts with label if-else Statement. Show all posts
Showing posts with label if-else Statement. Show all posts

Java - If-else Statement & Using Program in Java

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”);
    }

  }
 }