What Do Two Question Marks in a Row in a Ternary Clause Mean?
It is simply a nested ternary statement. Clearer by adding parentheses:
number == null ? (required ? 1 : 2) : 3;
what would the inputs need to be for 2 to be returned?
number = null
and required = false
This is why it’s always a good idea to explicitly add parentheses, so the intent is clear at a glance :
Integer val = number == null ? (required ? 1 : 2) : 3;