I have written my own implementation of java.utils.List. Now I’d like to test it, but I cannot manage to fill my collection with objects since it shows <identifier> expected whenever I add anything :
public static void main(String[] args) {}
MyCollection col = new MyCollection(10);
int[] tab = {1,2,4,5,6};
col.add(tab);
And the whole code here :
http://paste.pocoo.org/show/291343/
EDIT
MyCollection<Integer> col = new MyCollection<Integer>(10);
Integer[] tab = {1,2,4,5,6};
col.add(tab);
still the same :/
You’re trying to add an
int[]as item of aCollection<Integer>which acceptsInteger(or autoboxedint) items only. This would only work if you have aCollection<int[]>(of which the added array would then be the sole item).To convert an
int[]to aCollection<Integer>, you need to loop over it:See also: