Problem:
I was working with Java array. Suddenly I got this error message, “exception in thread "main" java.lang.nullpointerexception”. Can somebody help me out urgently, please? I am attaching the declaring part of my code below for your better understanding.
Thanks in advance.
import java.util.Scanner;
public class TestClass {
public TestClass() {
double percentage;
double n[] = 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 < 7; i++) {
System.out.print("\nMarks in subject " + (i + 1) + "\t:\t");
var = scan.nextDouble();
n[i] = var;
total = total + n[i];
//percentage = first * second * third * fourth * fifth * sixth * seventh * 100 / 700;
}