public class table
{
private int raw=0;
private int column=0;
private List<ArrayList<Integer>> TABLE ;
private static int COUNT_ELEMENTS_IN_RAW=0;
private static int COUNT_ELEMENTS_TOTAL=0;
private List<Integer> singleRaw ;
public table()
{
TABLE = new ArrayList<ArrayList<Integer>>();
singleRaw = new ArrayList<Integer>();
}
public void addELEMENT(Integer value)
{
if(!TABLE.equals(null))
{
singleRaw.addAll(TABLE.get(raw));
singleRaw.add(value);
COUNT_ELEMENTS_IN_RAW++;
if(COUNT_ELEMENTS_IN_RAW%14==0)
{
raw++;
COUNT_ELEMENTS_IN_RAW=0;
COUNT_ELEMENTS_TOTAL++;
}
}
}
}
这里我试图模拟二维表(xy),函数 addELEMENT 执行插入“表”。任何人都可以解释我为什么给我这个错误?
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at pt.iul.poo.games.table.addELEMENT(table.java:27)