Ternary Operator

 package conditionalStatements;


public class TernaryOperator {


public static void main(String[] args) {


int a = 15;

int b = 80;

int max = 0;

//

// if(a>b) {

// max = a;

// } else {

// max = b;

// }

max = a>b ? a : b;

System.out.println("Max of both numbers is " + max);

}


}


Comments

Popular posts from this blog

Simple Intrest

Else if

Sum of Digits