Question: JAVA language: Why am i getting this error and how to fix CODE: package ilstu.edu; import java.util.*; import java.io.*; import java.util.*; import java.lang.*; public class

JAVA language: Why am i getting this error and how to fix

CODE:

package ilstu.edu; import java.util.*; import java.io.*; import java.util.*; import java.lang.*; public class StudentReport {

public static String[] students = null ; public static int [][]grades = null ; public static void main(String[] args) throws IOException { // TODO Auto-generated method stub readFile(); System.out.println(students[0] + " " + grades[0]); }

public static void readFile() throws IOException { String info[] ; int ind = 0 ; try { Scanner sc = new Scanner(new File("Grades.csv")); String random = sc.nextLine() ; while (sc.hasNext()) { info = sc.nextLine().split(","); students[ind] = info[0]; grades[ind][0] = Integer.parseInt(info[1]) ; grades[ind][1] = Integer.parseInt(info[2]) ; grades[ind][2] = Integer.parseInt(info[3]) ; ind++; } sc.close(); } catch (FileNotFoundException e) { System.out.println("** File Not Found **");

} } }

NOTE:

-yes theres a .csv

-in the ilstu.edu package

-ERROR states: Exception in thread "main" java.lang.NullPointerException at ilstu.edu.StudentReport.main(StudentReport.java:20)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!