3
I’m learning about Array and I’m racking my brain with this code, can someone explain to me why it’s not working?
This error appears
The type List is not Generic; it cannot be parameterized with Arguments
in this line List<Integer> lista = new ArrayList<Integer>();
package DeclaracaoArray;
import java.awt.List;
import java.util.ArrayList;
import java.util.Collections;
public class Declaracao_Array {
public int sorteia(){
List<Integer> lista = new ArrayList<Integer>() ;
lista.add ( "Alice" ) ;
lista.add ( "Bruno" ) ;
lista.add ( "Carlos" ) ;
lista.add ( "Daniel" ) ;
Collections.shuffle ( lista ) ;
// pega qualquer indice. pegamos o primeiro para conveniencia.
return (( Integer ) lista.get ( 0 )).intValue () ;
}
}
Don’t edit the question that way, you’ve completely changed what you were asked before and now it seems that the answers you post don’t make sense. If that problem has been solved, mark the correct answer and then create a new question to address that new bug you are having.
– Renan Gomes
@Renan the problem as a whole (with arraylist) continues Renan, only changed the error message, so I did not create another question.
– Paulo Roberto
The first problem was that you were importing the object
List
wrong package. Now it’s because your class doesn’t have a methodmain
.– Renan Gomes
I get it @Renan, I’ll close this question, thank you!
– Paulo Roberto