title: Object is null after being initialized in a method
body: <p>I'm new to programming and I have a problem in my code.
  I start by initializing the Maze object to null because I don't know which will be the choice of the user. It is initialized in the method createMaze() but when I call printMaze it is null.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
      public static final String EXITGAME = "EXIT";
      public static final String PRINTBOARD = "PRINT";
      public static final String CREATEMAZE = "UPLOAD";
  
      public static void main(String[] args) {
          Scanner in = new Scanner(System.in);
          Maze maze = null;
  
          menu(maze,in);
      }
  
      private static void menu(Maze maze, Scanner in){
          String option = in.nextLine();
          while(option.toUpperCase() != EXITGAME){
              switch(option.toUpperCase()){
                  case PRINTBOARD: printMaze(maze); break;
                  case CREATEMAZE: createMaze(in,maze); break;
              }
              System.out.println();
              option = in.nextLine();
          }
      }
  
      private static void printMaze(Maze maze){
          if(maze != null){
              int maxX = maze.getxSize();
              int maxY = maze.getySize();
  
              for(int x = 0; x &lt; maxX; x++){
                  for(int y = 0; y &lt; maxY; y++){
                      System.out.print(maze.getMazeRepresentation(x, y));
                  }
                  System.out.println();
              }
          }
          else
              System.out.println("Maze is undefined");
      }
  
      private static void createMaze(Scanner in, Maze maze){
          if(maze == null || !maze.getGameStatus()){
              int x = in.nextInt();
              int y = in.nextInt();
              in.nextLine();
              char rawMaze[][] = new char[x][y];
  
              maze = new MazeClass(x,y);
  
              for(int i = 0; i &lt; x; i++){
                  createMazeLine(in,i,y, rawMaze);
              }
              maze.createMaze(rawMaze);
          }
          else
              System.out.println("Maze already defined.");
      }
  
      private static void createMazeLine(Scanner in, int lines, int y, char[][] rawMaze){
          String line = in.nextLine();    
  
          for(int i = 0; i &lt; y; i++){
              rawMaze[lines][i] = line.charAt(i);
          }
      }
  }
  </code></pre>