question mark colon java code example
Example: java question mark operator
//ternary operator
// takes in a conditional statement
// a is returned when the condition is true and vice versa
return (a == b) ? a : b;
int n = (a < b) ? a + 10: b;
//ternary operator
// takes in a conditional statement
// a is returned when the condition is true and vice versa
return (a == b) ? a : b;
int n = (a < b) ? a + 10: b;