I am using and Arraylist for sor soil samples because I don't know the number of samples and the depth of each sample. I am having a problem setting up my Arraylist and would appreciate some help.
In general the sample can be handled with a two diminsional array.
int layerdepth = new int; // where layerdepth[sample number
int watercapity = new int; // where water capacity[sample number
I thought I could add this to an Arraylist By:
ArrayList asoildata = new Arraylist;
asoildata.add(sample number, layerdepth);
But it will not work. I need to retrieve data by sample number, and suggestions would be appreciated.
There aren't really multi-dimensional arrays in Java, just arrays of arrays. So you should get the desired behaviour with an ArrayList of ArrayLists (though without the convenient regular array notation).