Conditonal Operators Examples in Java


Here is the simple program for printing conditional operators in Java.

Source Code

import java.io.*;
import java.util.Scanner;
class cond_ope
{
 public static void main(String args[])
 {
  /*
    Tutor Joes Computer Education
    www.tutorjoes.com
    Conditional Operator
    (10>5) ? statement 1 : Statement 2
  */
  int a,b,c;
  a=45;
  b=65;
  c=(a>b)?a:b;
  System.out.print("\nThe Greatest Number is  : "+c);
 }
}
To download raw file Click Here

Output

The Greatest Number is  : 65


Learn All in Tamil © Designed & Developed By Tutor Joes