(java@oneshot)logo/  logo/  logo/  logo/


 

Java Tutorial » Operators » Operators  
3.1.4.The ternary operator (The Conditional Operator): result = value>conditionValue ? result1 : result2Previous/Next
if(value > conditionValue){
  result = result1;
}else{
  result = result2;
}

 logical_expression ? expression1 : expression2
public class MainClass {
  public static void main(String[] args) {
    int v = 1;
    System.out.println(v == "A" "B");

    v++;
    System.out.println(v == "A" "B");
  }
}
A
B
3.1.Operators
3.1.1. Six categories of operators
3.1.2. Operator Precedence
3.1.3. The op= Operators
3.1.4. The ternary operator (The Conditional Operator): result = value>conditionValue ? result1 : result2
3.1.5. Tests all the operators on all the primitive data types to show which ones are accepted by the Java compiler