Java Command line option list navigation
<p>I've created a case switch option list, </p>

<p>First option list<br/>
option 1 go to option list A <br/>
option 2 go to option list B<br/>
option 3 haven't decided what this will do yet C<br/>
option 4 Exit<br/></p>

<p>if option 1 is selected<br/>
option 1 Do A<br/>
option 2 Do B<br/>
option 3 Do C<br/>
option 4 previous Menu<br/>
option 5 Exit<br/></p>

<p>So basically its a switch inside a switch. The bit I'm stuck on is returning to the previous menu.</p>

<pre><code>while (true) {
        System.out.println("Choose which Sort type to use\n");
        System.out.println("(1): Option 1 - do something\n(2): Option 2 - do something else\n(3): Option 3 - Something Cool\n(4): Exit");
        option = in.nextInt();

        if (option == 4) {
            System.exit(0);
        }


        switch (option) {

        case 1:

            while (true) {
        System.out.println("Choose which Sort type to use\n");
        System.out.println("(1): Option 1 - do something\n(2): Option 2 - Do something else\n(3): Option 3 - Something Cool\n(4): Exit");
        option = in.nextInt();

        if (option == 4) {
            System.exit(0);
        }


        switch (option) {

        case 1:

            while (true) {

            System.out.println("Choose which Sort type to use\n");
            System.out.println("(1): Option 1 -something\n(2): Option 2 - something else\n(3): Option 3 - something else\n(4): Option 4 - Previous Menu\n(5): Exit\n");
            option = in.nextInt();
            if (option == 5) {
                System.exit(0);
            }


            switch (option) {

            case 1:

                break;
            case 2:

                break;
            case 3:

                break;
            case 4:

            default:
                System.out.print("Please enter a valid option 1, 2 or 3");
                break;
            }//end of switch


        }//end of while loop





        case 2:
            while (true) {

                System.out.println("Choose which something type to use\n");
                System.out.println("(1): Option 1 - something\n(2): Option 2 - something\n(3): Option 3 - something\n(4): Exit");
                option = in.nextInt();
                if (option == 4) {
                    System.exit(0);
                }


                switch (option) {

                case 1:

                    break;
                case 2:

                    break;
                case 3:


                    break;
                default:
                    System.out.print("Please enter a valid option 1, 2 or 3");
                    break;
                }//end of switch


            }//end of while loop











        case 3:

            break;
        default:
            System.out.print("Please enter a valid option 1, 2 or 3");
            break;
        }//end of switch

        }
</code></pre>
