DEV Community

hema latha
hema latha

Posted on

Ternary operator :

public static void main(String[] args) {
// TODO Auto-generated method stub
int time = 20;
String result = (time < 18) ? "Good day.":"Good evening.";
System.out.println(result);
}

out put - Good evening

task 2
public static void main(String[] args)
{
int no1 = 100, no2=200;
int bigger= (no1>no2)? no1 :no2;
System.out.println(bigger);
}
out put = 200

Top comments (0)