0

Can any one described how ternary operator work with examples?

13th Sep 2017, 9:12 AM
Xerox
Xerox - avatar
2 Respostas
+ 10
public static void main(String[] args) { int a = 5; boolean result1 = if_statement(a); boolean result2 = ternary(a); System.out.println("result1="+result1); System.out.println("result2="+result2); } static boolean if_statement(int a){ if(a==5){ return true; }else{ return false; } } static boolean ternary(int a){ return a==5 ? true : false; } //Output result1=true result2=true
13th Sep 2017, 9:27 AM
Corey
Corey - avatar