lundi 7 décembre 2015

"no suitable method found for add(java.lang.String)"in arraylist constructor?

import java.util.ArrayList; import java.util.Random;

public class College
{
    // instance variables - replace the example below with your own
    private ArrayList<Student> students;

public College()
    {
        // initialise instance variables
        ArrayList<Student> students = new ArrayList<Student>();
        students.add("Student 1");
        students.add("Student 2");
        students.add("Student 3");

    }
}

basically it highlights the .add showing the error message "java.lang.IllegalArgumentException: bound must be positive", I don't understand what I did wrong here? I looked at a lot of these kinds of problem threads here but I did exactly what they did




Aucun commentaire:

Enregistrer un commentaire