title: How can I solve Exception in thread "main" java.lang.NullPointerException error
body: <p>I am having a problem at a Java program. Exception in thread "main"</p>
  
  <pre><code>java.lang.NullPointerException
  at twoten.TwoTenB.&lt;init&gt;(TwoTenB.java:29)
  at javapractice.JavaPractice.main(JavaPractice.java:32)
  Java Result: 1 
  </code></pre>
  
  <p>is the error that I'm getting. I could really use some help, since i am stuck hours on this spot...</p>
  
  <pre><code>package twoten;
  
  import java.util.Scanner;
  
  public class TwoTenB {
  
  public TwoTenB() {
      double percentage;
      double a[] = null;
      double total = 0;
      double var;
      System.out.print("\tRESULT\n\n");
      Scanner scan = new Scanner(System.in);
      //double[] mark = new double[7];
      for (int i = 0; i &lt; 7; i++) {
  
          System.out.print("\nMarks in subject " + (i + 1) + "\t:\t");
          var = scan.nextDouble();
  
          a[i] = var;
  
          total = total + a[i];
         //percentage = first * second * third * fourth * fifth * sixth * seventh * 100 / 700;
      }
  
      percentage = total * 100 / 700;
  
      if (a[0] &gt; 35 &amp;&amp; a[1] &gt; 35 &amp;&amp; a[2] &gt; 35 &amp;&amp; a[3] &gt; 35 &amp;&amp; a[4] &gt; 35 &amp;&amp; a[5] &gt; 35 &amp;&amp; a[6] &gt; 35 &amp;&amp; percentage &gt; 35) {
          if (percentage &gt;= 60) {
              System.out.print("\nCongratulation!!! you've got FIRST dividion\n");
          } else if (percentage &gt;= 45 &amp;&amp; percentage &lt; 60) {
              System.out.print("\nCongratulation!!! you've got SECOND dividion\n");
          } else if (percentage &gt;= 35 &amp;&amp; percentage &lt; 45) {
              System.out.print("\nCongratulation!!! you've got THIRD dividion\n");
          }
      } else {
          System.out.print("\nSORRY!!! you've FAILED\n");
      }
      }
  }
  </code></pre>