2
votes
3answers
483 views

Checking “instanceof” rather than value using a switch statement

Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this: switch ...
30
votes
8answers
2k views

Is it necessary to add the default case while using switch cases?

During a recent code review I was asked to put default cases in all the files wherever switch block is used, even if there is nothing to do in default. That means I have to put the default case and ...
9
votes
5answers
714 views

If-Else V.S. Switch end of flow

I was wondering the if if-else statements, is like a switch statement that does have a break statement. if( boolean_expression_1 ) statement_1 else if( boolean_expression_2 ) statement_2 else ...
7
votes
4answers
1k views

How is a switch statement better than a series of if statements? [duplicate]

Possible Duplicate: Should I use switch statements or long if…else chains? I'm working on a small program that will conduct an Insertion Sort. A number will be inputted through the ...