Exception error with class and files : <p>I have a file on my computer called records.txt with a few lines on it. Each line has the format "firstname - lastname - address - age - gpa"</p>

<p>Adam - Michael - Gainesville florida - 16 - 75</p>

<p>Alice - Barry - Jacksonville florida - 17 - 40</p>

<p>Kevin - Adam - Orlando florida - 20 - 65</p>

<p>Jacob - Michael - Miami florida - 16 - 88</p>

<p>Sabrina - Matthew - Gainesville florida - 18 - 90</p>

<p>My program is supposed to separate those and display the information using a class of students. The cgpa is the letter grade given by the bounds shown in my code for the gpa. This is the error my code gives me.</p>

<pre><code>     Exception in thread "main" java.lang.NullPointerException
at hw6_hamilton_daniel.HW6_Hamilton_Daniel.main(HW6_Hamilton_Daniel.java:41)
C:\Users\dhami\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
</code></pre>

<p>Here is my coding:</p>

<p>MAIN:</p>

<pre><code>package hw6_hamilton_daniel;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
*
* @author dhami
*/
public class HW6_Hamilton_Daniel {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {

    try {

        File records = new File("C:\\Users\\dhami\\Desktop\\records.txt");
        Scanner input = new Scanner(records);

        int count = 0;
        while (input.hasNextLine()) {
            count = count + 1;
            break;
        }
        input.close();

        student[] students = new student[count];
        Scanner input2 = new Scanner(records);

        for (int i = 0; i &lt; count; i++) {

            String line = input2.nextLine();
            String[] Split = line.split(" - ");

            students[i].set_firstname(Split[0]);
            students[i].set_lastname(Split[1]);
            students[i].set_address(Split[2]);
            students[i].set_age(Split[3]);
            students[i].set_gpa(Split[4]);

            students[i].Display_info();
            break;
        }
        input2.close();
    } catch (FileNotFoundException ex) {
        System.out.println("File Not Found");
    }//IF FILE IS NOT ON MACHINE

}
</code></pre>

<p>}</p>

<p>CLASS:</p>

<pre><code>public class student {

private String firstname;
private String lastname;
private String address;
private int age;
private int gpa;
private char cgpa;

student() {
    firstname = "Default_FName";
    lastname = "Default_LName";
    address = "Default_Address";
    age = 0;
    gpa = 0;
    cgpa = 'X';
}//Default constructor

void set_firstname (String new_name) {
    firstname = new_name;
}
String get_firstname () {
    return firstname;
}//firstname-------------

void set_lastname (String new_lastname) {
    lastname = new_lastname;
}
String get_lastname () {
    return lastname;
}//lastname--------------

void set_address (String new_address) {
    address = new_address;
}
String get_address () {
    return address;
}//address---------------

void set_age (String new_age) {
    age = Integer.parseInt(new_age);
}
int get_age () {
    return age;
}//age-------------------

void set_gpa (String new_gpa) {
    gpa = Integer.parseInt(new_gpa);

    if (gpa &gt;= 85 &amp;&amp; gpa &lt;= 100) {
        cgpa = 'A';
    }
    if (gpa &gt;=60 &amp;&amp; gpa &lt;= 85) {
        cgpa = 'B';
    }
    else {
        cgpa = 'C';
    }
}
int get_gpa () {
    return gpa;
}//gpa-------------------
char get_cgpa () {
    return cgpa;
}

void Display_info() {
    System.out.println("First Name: "+firstname);
    System.out.println("Last Name: "+lastname);
    System.out.println("Address: "+address);
    System.out.println("Age: "+age);
    System.out.println("GPA: "+gpa+" ("+cgpa+")\r\n");
}
    }
</code></pre>
