【发布时间】:2015-12-24 06:49:01
【问题描述】:
我正在修改我的问题以使其更易于理解。 我有以下数组列表
ArrayList<AnotherClass> exmapleName = new ArrayList<AnotherClass>();
// AnotherClass is a class I created, I store objects of the class in this array, the code to this doesn't matter this works.
在exampleName里面我有不同类型的数据
public AnotherClass (String someString, int someInt, int anotherInt, int[] intArray, ArrayList<Integer> arrayList)
//Header of the constructor
现在我需要做的是访问和存储arrayList[0]。但是一旦创建了对象,我就需要这样做,所以arrayList里面实际上有一些东西。
这是我尝试过但似乎不起作用的方法
AnotherClass test1 = exampleName.get(1);
ArrayList<Integer> test2 = test1.arrayList;
int test3 = test2.arrayList[0];
// I broke it down into separate lines to make it more understandable
编译错误如下
cannot find symbol
int test3 = test2.arrayList[0];
symbol: variable arrayList
location: variable test2 of type ArrayList<Integer>
1 个错误
【问题讨论】:
-
你有一个 int[] 的 ArrayList?这是你的类型的数据。@Blueaddiction