samedi 23 octobre 2021

Conditional Operator without if...else in java

So recently I got a question that how to perform the function of if...else without if...else. Like if a program is to find the greater between integer a and b, one would easily write that

if (a>b){
   System.out.println("a is greater");
}else {
System.out.println("b is greater");
}

Is there any other way to do this without if...else method?

Aucun commentaire:

Enregistrer un commentaire