I'm creating a list of Students, but I find myself in the following situation. At point 2 give me error because it says that I have to get the Student inside the List but when I do point 1 is already correct. Can anyone tell me a practical example because?
The goal is supposedly to have main as point 2. And inside the ArrayList has nothing. What do they advise me? To do as point 1?
public static void main(String[] args) {
(1) ArrayList<Estudante> lista = new ArrayList<Estudante>(); //assim dá mas com List e arraylist nao da porque?
(2) List <Estudante> lista1 = new ArrayList<>();
}
Even if you do this:
List<Estudante> lista1 = new ArrayList<Estudante>();
The List is giving error: The type List is not generic; it can not be parameterized with arguments Student
My student class has only the number and name:
public class Estudante {
private int numero;
private String nome;
public Estudante(int numero, String nome){
this.numero = numero;
this.nome = nome;
}