I'm practicing with some tutorials and I had a problem. Can not I add a int
object to the list?
package paquete;
import java.util.*;
import java.util.LinkedList;
class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList list = new LinkedList();
list.add("Perro");
list.add(0, "Gato");
list.add(5);
The problem is in list.add(5);
that when I execute it I throw this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method add (int, Object) in the type LinkedList is not applicable for the arguments (int)
at package.Main.main (Main.java:14)
I hope you can help me!