Java - Place default statement in the middle of switch cases

Introduction

The default label may not be the last label to appear in a switch statement and is optional. For example,

Demo

public class Main {
  public static void main(String[] args) {
    int i = 50;//from w  w w  .j a v a 2s  . c  om
    switch (i) {
    case 10:
      System.out.println("Ten");
    default:
      System.out.println("No-match"); // Execution starts here
    case 20:
      System.out.println("Twenty");

    }
  }
}

Result

Related Topic