title: Java error: java.lang.NullPointerException
body: <p>I'm writing a code to read some records from a file and sort them in a special manner. I tried a code like this:</p>
  
  <pre><code>public class Main {
  
      static class judgement implements Comparable&lt;judgement&gt; {
          public int q;
          public int d;
          public int r;
  
          public int compareTo(judgement j) {
              int k = ((judgement) j).q;
              return 0;
          }
      }
  
      public static void method() throws Exception {
          judgement[] judgements;
          judgements = new judgement[18425];
          try {
              // fill the "judgements" array
          } finally {
              Arrays.sort(judgements);
          }
      }
  
      public static void main(String[] args) throws Exception {
          method();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>But I get the error <em>NullPointerException</em> in the function compareTo. Can anybody help me with this problem?</p>