I\'m new to Java and is trying to learn the concept of shorthanded if-else statement.
if-else
I have came up with the code below. However, the code wouldn\'t c
The ternary expression
condition ? when-true : when-false
is an expression, not a statement, so can't be used where a statement is required.
You can write this as:
msi1.put(s1, (i1 == null) ? i1 : i1 + 1);
because this is a statement.