Can Java handle nested switch statements?

Byron Tymvios

Nested switch statements are allowed. Just make sure you remember to have all the break statements in the correct places. E.g:

int i;
int j;

    case 0: System.out.println("i is 0"); break;
    case 1: System.out.println("i is 1");
        case 0: System.out.println("j is 0"); break;
        case 1: System.out.println("j is 1"); break;
        default: System.out.println("j is not known");
      } break; //note this break after 2nd switch
    default: System.out.println("i is not known");