title: How to use an object reference in a whole class
body: <p>so for example in a switch statement "case 1" I declare an Object reference variable, its all good, but if I try to use in a "case 2" it says that reference variable cannot be resolved.</p>
  
  <p>How can I use it in every case?</p>
  
  <p>Edit:</p>
  
  <pre><code>switch(choice){ 
                  case 1: {
                      if(HotelObj.getClassicRoomsAvailable() == 0 &amp;&amp; HotelObj.getExecutiveRoomsAvailable() == 0){
                          System.out.println("Sorry, there are no available rooms");
                          break;
                      }else {
                          Scanner scanInput = new Scanner(System.in);
                          System.out.print("\nEnter desired room type: ");
                          System.out.print ("\nEnter \"Classic\" for a classic type room, price: 90$ for a day");
                          System.out.println("\nEnter \"Executive\" for a executive type room, price: 150$ for a day");
                          String roomChoice = scanInput.nextLine();
  
                          System.out.print("Enter your name: ");
                          String clientName = scanInput.nextLine();
                          System.out.print("Enter for how many days you'll stay:");
                          int stayingDays = scanInput.nextInt();
  
                          Client ClientObj = new Client(clientName, roomChoice, stayingDays);
  
                          Client.clientCount++;
                              if(roomChoice.equals("Classic")){
                                  ClientObj.clientRoom = new Room("Classic");
                                  ClientObj.setMoney(ClientObj.getMoney()- stayingDays * ClientObj.clientRoom.getPrice());
                                  HotelObj.decClassicRooms(1);
                                  HotelObj.addIncome(stayingDays*ClientObj.clientRoom.getPrice());
                              } else {
                                  ClientObj.clientRoom = new Room("Executive");
                                  ClientObj.setMoney(ClientObj.getMoney()-stayingDays * ClientObj.clientRoom.getPrice());
                                  HotelObj.decExecutiveRooms(1);
                                  HotelObj.addIncome(stayingDays*ClientObj.clientRoom.getPrice());
                              }                    
                      }
                      break;
                  }
  
                 case 2: {
                     System.out.println("Name: "+ClientObj.getName());
                     //Error "ClientObj cannot be resolved"
                 }
              }
  </code></pre>