In the switch statement in Java, each case branch is a single entry, and if none of the conditions are met, it will go to the default branch. So will the location of the default branch affect the execution process?
Package com.app.statement;import java.util.scanner;/** * created by charles on 2015/7/12. */public class SwitchTest { public Static void main (String[] args) { System.out.print ("Enter a digital number:"); Scanner scanner = new scanner (system.in); Int number = scanner.nextint (); switch (number) { default:            SYSTEM.OUT.PRINTLN ("Default"); break; case 1: system.out.println ("1"); break; case 2: System.out.println ("2"); case 3: System.out.println ("3"); case 4: System.out.println ("4"); } }}
Test conditions: 5
Execution Result: Default
Description if the case statement does not match, the position of the Defualt statement does not affect the process.
Test conditions: 2
Execution Results: 2 3 4
After the entry of the case statement, the flow of the statement executes sequentially down, not to the default statement. So the default statement should be written in the last place, or it might not be executed. Test jdk:1.7
The location of the defaul condition in the switch statement in Java