What does “?” mean in Java?

someval = (min >= 2) ? 2 : 1;

This is called ternary operator, which can be used as if-else. this is equivalent to

if((min >= 2) {
   someval =2;
} else {
   someval =1
}

Follow this tutorial for more info and usage.

Leave a Comment

tech