Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

The Type List is not generic, it cannot be parameterized with arguments

Bom dia galera, o exercicio é simples Criar um Objeto Curso que possui nome, instrutor e uma list de aulas, porem na hora de criar a List no método main ele nao aceita...Passando o mouse em cima de list me aparece o seguinte: The Type List is not generic, it cannot be parameterized with arguments Abaixo os códigos:

public class Aula implements Comparable<Aula>{
    private String titulo;
    private int tempo;

    public Aula(String titulo, int tempo){
        this.titulo=titulo;
        this.tempo=tempo;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public int getTempo() {
        return tempo;
    }

    public void setTempo(int tempo) {
        this.tempo = tempo;
    }

    public String toString(){
        return "Aula :" + this.titulo + " Tem " + this.tempo + " Minutos ";
    }

    public int compareTo(Aula outraAula){
        return this.titulo.compareTo(outraAula.titulo);
                }



}
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Curso {

    private String nome;
    private String instrutor;
    private List<Aula> aulas = new LinkedList<Aula>();

        public Curso(String nome, String instrutor) {
        this.nome = nome;
        this.instrutor = instrutor;
    }
    public String getNome() {
        return nome;
    }
    public String getInstrutor() {
        return instrutor;
    }
    public List<Aula> getAulas(){
        return Collections.unmodifiableList(aulas);//readyOnly nao add nem remove
    }
    public void adiciona(Aula aula){
        this.aulas.add(aula);
    }


}
import java.awt.List;
import java.util.Collections;

public class TestaCurso2 {
    public static void main(String[] args) {

        Curso avancado = new Curso("Curso Java Avancado", "Antonio Conrado");
        //List<Aula> aulasAvancadas = avancado.getAulas();

        avancado.adiciona(new Aula("Orientacao a Objetos", 120));
        avancado.adiciona(new Aula("Descobrindo Threads",50));
        avancado.adiciona(new Aula("Colecoes de dados", 40));

        List<Aula> aulas = avancado.getAulas();
        System.out.println(aulas);

        }
}
2 respostas
solução!

Oi Antonio,

Sem querer você importou java.awt.List Ao invés de importar java.util.List.

Abraço!

Ahhh sim =D , Obrigado

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software