package com.kt4study.corejava.operators;
/**
* @author kt4study.blogspot.co.uk
*
*/
public class TernaryOperatorExample {
public static void ternaryOperator(){
int a = 10;
int b = 5;
int result;
// ?: Ternary Operator Example
result = ((a+b) == 15) ? 1000 : 2000 ;
System.out.println("Result :: " + result);
}
public static void main(String[] args) {
TernaryOperatorExample.ternaryOperator();
}
}
/*Output -->
Result :: 1000
*/
|
No comments:
Post a Comment