title: Null Pointer Exception calling String[] from another class
body: <p>My problem is just that. I've tried to declare the string as a specific size, I sort and everything, but the only thing that's worked is putting the string in the main method inside the main class that I use. It's frustrating, because I've tried everything that I can think of. Why are the elements becoming void when I import them from another class? I added a main method to the moves class and moved it there to try it too, but to no avail.
  Here's the first program:</p>
  
  <pre><code>    import java.util.Arrays;
  public class movesClass {
      public String[] getMoves() {
          return moves;
      }
      String[] moves;
      public static String[] useMove(String[] moves) {
          moves[0] = "punch";
          moves[1] = "kick";
          moves[2] = "defend";
          moves[3] = "run";
          moves[4] = "inventory";
          moves[5] = "rickroll";
          moves[6] = "heal";
          Arrays.sort(moves);
          return moves;
      }
  }
  And the body of the main one:
  
      import java.io.*;
  import java.util.*;
  public class practiceBattle {
      public static void main(String[] args) {
  
          Scanner scan = new Scanner(System.in);
          Random rand = new Random();
          inventoryClass quant = new inventoryClass();
          movesClass mov = new movesClass();
          String[] moves = mov.getMoves();
  
          int hp = 0;
          int playerHp = 200;
  
          String input = "default";
  
          int damage = 0;
  
          int hitDif = 50; //default
          int kickChance1 = 0; //default -- goes into hitChance
          int kickChance = kickChance1 - hitDif; //chance to hit
          int hitChance1 = 0;
          int hitChance = hitChance1 - hitDif;
  
          int runDif = 50; //default
          int runChance1 = 0; //default -- goes into runChance
          int runChance = runChance1 - runDif; //chance to run
  
          int enemyMinAttack = 0;
          int enemyAttack = 0;
  
          int index = 0;
  
          int[] levelArray = {1, 2, 3};
          String[] monsterArray = {"GNOLL", "TROLL", "DRAGON"};
          String monster = monsterArray[rand.nextInt(monsterArray.length)];
          int level = rand.nextInt(levelArray.length) + 1;
          if(level == 1)
          {
              System.out.println("YOUR OPPONENT IS A BABY " + monster + "!");
          }
          else
          {
              System.out.println("YOUR OPPONENT IS A LEVEL " + level + " " + monster + "!");
          }
          if(level == 1)
          {
              hp = rand.nextInt(20) + 41;
              enemyAttack = rand.nextInt(5) + 1;
          }
          else if(level == 2)
          {
              hp = rand.nextInt(20) + 91;
              enemyAttack = rand.nextInt(6) + 5;
          }
          else if(level == 3)
          {
              hp = rand.nextInt(20) + 141;
              enemyAttack = rand.nextInt(7) + 10;
          }
          enemyMinAttack = rand.nextInt(enemyAttack) + 1;
  
          System.out.println("YOUR OPPONENT'S HP IS: " + hp + "\n");
          int permEnemyAttack = enemyAttack;
          int permEnemyMinAttack = enemyMinAttack;
  
  
  
  
  
  
  
      ext:
          while(hp &gt; 0)
          {
              enemyAttack = permEnemyAttack;
              enemyMinAttack = permEnemyMinAttack;
  
              do
              {
                  if(playerHp == 0)
                  {
                      System.out.println("YOU HAVE DIED. GAME OVER!\n\n\n");
                      break ext;
                  }
                  else
                  {
                      System.out.println("Choose an action:\nkick\npunch\nrun\ndefend\n");
                      input = scan.nextLine();
  
  
                      index = Arrays.binarySearch(moves, input);
                      System.out.println(index);
                      if(index &lt; 0)
                      {
                          System.out.println("\n\n\nINVALID INPUT -- TRY AGAIN\n\n\n");
                      }
                  }
  
              } while(index &lt; 0);
  </code></pre>
  
  <p>That's what I have of the main one, up to where the problem ends and from where it begins.
  Any inpu would be greatly appreciated. Thank you!</p>