-1
I have a main class and another class, basically I have to read a CSV file in which the first line will have the materials of a student (matematica, portugues etc). The number of materials is N can be 8 or 800, so I recorded these materials in an arraylist. The teacher must compute grades to Kd student per subject, but he can also add subject or add and remove students, so I thought of working with another arraylist. The problem is that when saving the information in an arraylist to compute the notes I cannot print the arraylist, I see the msg ([Ljava.lang.String;@7e0babb1). Any idea what can be done to solve?
main class
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import OpenFile.Marks;
public class OpenFile {
public static void main(String[] args) {
Scanner fileIn = new Scanner(System.in);
ArrayList<String> firstRowSplit = new ArrayList<String>();
String readerFirstLine;
int n = 0 ; //using to count the lines in the file csv // for get the first row
try {
fileIn = new Scanner(new FileReader("marks.csv")); // open the file marks.csv
while ( n == 0 ) { // read the file csv and get the first line
readerFirstLine = fileIn.nextLine(); // put the 1 line of file in a string
n++;
System.out.println(readerFirstLine);
firstRowSplit = new ArrayList<String>(Arrays.asList(readerFirstLine.split(","))); //put the string(1º row) to into an arraylist
}
}//try
catch (FileNotFoundException e) {
System.out.println("Error: " + e.getMessage());
} // end catch
for (int i = 0; i < firstRowSplit.size(); i++) { //copy the arraylist elements for the object arraylist
Marks.setMarkingCriteria(firstRowSplit);
//System.out.println(firstRowSplit.get(i));
}
Marks.add();
Marks.show();
Scanner in = new Scanner (System.in);
}//main
}//end
and subclass
package OpenFile;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import java.util.ArrayList;
public class Marks {
private static ArrayList <String> markingCriteria = new ArrayList<String>();
private static ArrayList<String> students = new ArrayList<String>();
private String id;
public static ArrayList<String> add() {
Scanner in = new Scanner(System.in);
String[] getGradeArray = new String[markingCriteria.size()]; //array to store marks
for(int i = 0; i< markingCriteria.size(); i++) {
System.out.println("tap the grade for: " + markingCriteria.get(i));
String getGrade = in.nextLine(); //read the marks
getGradeArray[i] = getGrade; //put the marks in an array
}
String stringOfMarks = getGradeArray.toString();
students.add(stringOfMarks);
return students;
}
public static ArrayList<String> show() {
for(int i = 0; i < students.size(); i++) {
System.out.println(students.get(i));
}
return students;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ArrayList<String> getMarkingCriteria() {
return markingCriteria;
}
public static void setMarkingCriteria(ArrayList<String> markingCriteria) {
Marks.markingCriteria = markingCriteria;
}
public ArrayList<String> getStudents() {
return students;
}
public void setStudents(ArrayList<String> students) {
this.students = students;
}
}