ja stworzenie ArrayList
i jego rozmiar jest 40
Initilize ArrayList zerami
ArrayList<Integer> myList= new ArrayList<>(40);
Jak mogę zainicjować myList
zerami 0
? Próbowałem to
for(int i=0; i<40; i++){
myList.set(i, 0);
}
ale mam
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
Zauważ, że 'Arrays.asList (new int [40])' zwraca 'List', więc powyższa instrukcja da błąd podczas kompilacji. –