[나크21] 캐주얼 미니스커트 치마바지 NK21-P-10
BLOG main image
분류 전체보기 (540)
▩▩ 개인공간 ▩▩ (124)
▩▩ 문화생활 ▩▩ (45)
▩▩ 게임 ▩▩ (211)
▩▩ 일러스트 ▩▩ (46)
▩▩ 프로그래밍 ▩▩ (73)
▩▩ 코스메틱 ▩▩ (1)
▩▩ 여행 ▩▩ (0)
* 셈틀 롤드컵 * (1)
반응형
Total
Today hit
Yesterday hit
▩▩ 프로그래밍 ▩▩/C#
반응형

Q.
ArrayList[] j = new ArrayList[4];
which gave me some nullPointer errors when I tried to add items to j[0].


A.
all the entries from your array will be pointing to null instead of an ArrayList.
After you create an array, you could loop through it and assign an ArrayList to each entry, that way you will not have those nasty null-pointer exceptions. Example:

ArrayList[] myList = new ArrayList[4];

for(int i = 0; i < myList.length; i++) {
    myList[i] = new ArrayList();
}

반응형