Conditional (? :) Operator in Java


The conditional operator is a shorthand for if-else statements, useful for simple conditions.

Source Code

int time = 20;
String result = (time < 18) ? "Good day." : "Good evening.";
System.out.println(result);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments