Ternary Operator in Java


The ternary operator is a shorthand for if-else statements that assign a value based on a condition.

Source Code

int score = 75;
String grade = score > 60 ? "Pass" : "Fail";
System.out.println(grade);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments