Java 从arraylist获取数组项

Java 从arraylist获取数组项,java,arrays,arraylist,Java,Arrays,Arraylist,我正在修改我的问题,使它更容易理解。 我有下面的arraylist 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. ArrayLis

我正在修改我的问题,使它更容易理解。 我有下面的arraylist

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.
ArrayList exmapleName=new ArrayList();
//另一个类是我创建的一个类,我将该类的对象存储在这个数组中,这个数组的代码并不重要。
在exampleName中,我有不同类型的数据

public AnotherClass (String someString,  int someInt, int anotherInt, int[] intArray, ArrayList<Integer> arrayList)
//Header of the constructor
public-AnotherClass(String-someString,int-somesint,int-anotherInt,int[]intArray,ArrayList-ArrayList)
//构造函数的标头
现在我需要做的是访问和存储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 
AnotherClass test1=exampleName.get(1);
ArrayList test2=test1.ArrayList;
int test3=test2.arrayList[0];
//我把它分成几行,以便更容易理解
编译器错误如下

cannot find symbol
                    int test3 = test2.arrayList[0];
symbol:   variable arrayList
location: variable test2 of type ArrayList<Integer>
找不到符号
int test3=test2.arrayList[0];
符号:变量数组列表
位置:ArrayList类型的变量test2
1错误

如果您使用的是“普通”数组,您只需访问带有索引的
i
-th元素,如
myArrayList.get(1).normalArray[i]

如果需要处理数组,请考虑将其存储到本地副本并从中访问。

int[] numbers = myArrayList.get(1);
for(Integer num : numbers){
  // Process the numbers array.
  System.out.print(num);
}

int first=arr[0];

我以前尝试过这个方法,但是我需要将变量存储为int,但是它需要一个整数数组R.java:70:error:array required,但是ArrayListfound@Blueaddiction你是说
normalArray
被声明为
ArrayList
?你在原来的帖子里没有这么说。你说的“int数组”被其他人误解了。请给我们看更多的代码。我说过主数组是一个整数数组列表,里面有一个int数组。当我回到它的时候,我会发布更多的代码休息一下我已经修改了主要的帖子来更清晰地反映问题你有一个int[]的ArrayList吗?这是您的数据类型。@BlueAddition实际等待它不起作用,错误:不兼容的类型://my other class-->(另一个类)无法转换为int[]int[]test1=eQuestion.get(1);你能不能再发一些代码,这样我就可以知道它是否仍然不适合你。
int first=arr[0];