看板 java 關於我們 聯絡資訊
我想做一個ArrayList<Color> array 所以我定義他as an array 然後Using this ArrayList a Generic Type private ArrayList<Color>[] my_blocklist; for(int index = 0; index < WIDTH; index++ ) { my_blocklist[index] = new ArrayList<Color>(); } 不過debug時,my_blocklist 是 null, 請問要如何declare 和 define 一個ArrayList<Color> array 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 131.191.35.253 ※ 編輯: cutewawa 來自: 131.191.35.253 (05/23 04:43)
jtmh:第一行沒 new 所以 my_blocklist 初初始為 null, 請加上 05/23 06:00
jtmh:my_blocklist = new ArrayList<Color>[WIDTH]; 05/23 06:01
zeat:我當初這樣用也忘了加樓上那行= ="" 05/23 13:53