title: How to get and set value in the switch-case statement
body: <p>I want to make a simple menu with 3 choices: </p>
  
  <p>'Create new employee', 'Display all employees' and 'Quit' in a Employee Manager(code below) but it was not successful(compiling error).</p>
  
  <p>BlueJ editor cannot realize the object 'm', 's' and 'l' in the 'case 2' statement. Is there anyway to get the value of the object in the 'case 1' and use them in the 'case 2'? Thanks a lot!</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Test
  {
      public static void main(String[] args)
      {
          int ch;
          do{
              System.out.println("EMPLOYEE MANAGER\n");
              System.out.println("1. Create new employees\n");
              System.out.println("2. Display all employees\n");
              System.out.println("3. Quit\n");
              System.out.print("Your choice: ");
  
              Scanner input = new Scanner(System.in);
              ch = input.nextInt();
  
              switch(ch){
                  case 1: System.out.println("== CREATE NEW EMPLOYEES ==");
                      System.out.println();
                      Manager   m = new Manager();
                      Scientist s = new Scientist();
                      Labourer  l = new Labourer();
                      m.newManager();
                      s.newScientist();
                      l.newLabourer();
                      System.out.println();
                      break;
  
                  case 2: System.out.println("==  PREVIEW  EMPLOYEES  ==");        
                      System.out.println();
                      m.display();
                      s.display();
                      l.display();
                      System.out.println();
                      System.out.println();
                      break;
                  case 3: System.exit(0);
                  default: System.out.println("Invalid choice!");
              }
          } while(ch &gt;= 1 &amp;&amp; ch &lt;=4);
      }
  }
  </code></pre>