ArrayList

Hi, im new to java so i cud use sum help

a. i need to delcare and construct an ArrayList to hold the rainfall (in mm) for each of the 12 months of the year.

b. during january there was 28mm of rain, and during february there was 45mm. i need to add these two numbers into the ArrayList.

Many Thanks

[323 byte] By [abdul.princea] at [2007-10-2 21:55:44]
# 1
ArrayList rainFall=new ArrayList(12);rainFall.add(new Integer(28));rainFall.add(new Integer(45));Hope this helpsBamkin
bamkin-ov-lestaa at 2007-7-14 1:11:46 > top of Java-index,Java Essentials,New To Java...
# 2
Yes it does help. Thank you very much.
abdul.princea at 2007-7-14 1:11:46 > top of Java-index,Java Essentials,New To Java...
# 3

To retrieve

int rainFallInMarch=rainFall(2).intValue();

It is not important that the inital capacity is 12 as the ArrayList will expand itself, however if you specify the correct size, the programme will run faster as the list does not have to resize

bamkin-ov-lestaa at 2007-7-14 1:11:46 > top of Java-index,Java Essentials,New To Java...