I've learnt how to Create an Arraylist of Objects , such arrays are dynamic in nature. e.g. to create an array of objects(instances of class Matrices ) having 3 fields, the code is like given below :
ArrayList<Matrices> list = new ArrayList<Matrices>();
list.add( new Matrices(1,1,10) );
list.add( new Matrices(1,2,20) );
Moreover, the Matrices
class goes like this:
public class Matrices{
int x;
int y;
int z;
Matrices(int x,int y, int z){
this.x = x;
this.y = y;
this.z = z;
}
}
Now, how can I access each fields of any element from this array name list
? In particular, how to access the 20
field from 2nd element of this array whose value is (1,2,20) ?