Back
Integer i = ...switch (i){ case null: doSomething0(); break; }
Integer i = ...
switch (i){
case null:
doSomething0();
break;
}
In the code above I cant use null in switch case statement. How can I do this differently? I can't use default because then I want to do something else.
Try:
switch ((i != null) ? i : DEFAULT_VALUE) { //...}
switch ((i != null) ? i : DEFAULT_VALUE) {
//...
31k questions
32.8k answers
501 comments
693 users