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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started