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).
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL