// This operator consists of three operands and is used to
// evaluate Boolean expressions. The goal of the operator is to decide which value should be assigned to the variable.
// The operator is written as:
// variable x =(expression)? value iftrue: value iffalse
public class ConditionalOperator {
public static void main(String[] args) {
int a,b;
a = 10;
b = (a == 1) ?50:51;
System.out.println("The value of b is: "+b);
b = (a == 10)?50:51;
System.out.println("The value of b is: "+b);
}
}

No comments:
Post a Comment