Hi,
I am trying to fill an array with strings but the code does not work:
static int numStudents = 20; Student[] students = new Student[numStudents]; String theFiller = "0"; Arrays.fill(students, theFiller);
I am getting:
Exception in thread "main" java.lang.ArrayStoreException: java.lang.String
at java.util.Arrays.fill(Arrays.java:2710)
at java.util.Arrays.fill(Arrays.java:2685)
at StudentDatabase.addStudent(StudentDatabase.java:90 )
at StudentDatabase.main(StudentDatabase.java:51)
when I try to use for loop:
I am getting "incompatible types"for (int i=0; i<length; i++) { students[i] = "0"; }
I have set/get methods set for class Student, can you help me prefill this array please?