olá possuo uma main class e uma outra classe, basicamente tenho que ler um arquivo CSV no qual a primeira linha terá as materias de um aluno (matematica, portugues etc). O numero de materias é N pode ser 8 ou 800, então gravei essas materias numa arraylist. O professor deve computar notas a kd aluno por materia, mas ele tambem pode acrescentar materia ou acrescentar e remover alunos, logo pensei em trabalhar com outra arraylist. O problema é que quando salvo as informções numa arraylist para computar as notas eu não consigo imprimir a arraylist, me aparece a msg ([Ljava.lang.String;@7e0babb1). Alguma ideia do que pode ser feito pra resolver?
main classe
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
e 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 markingCriteria = new ArrayList();
private static ArrayList students = new ArrayList();
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;
}
}