25 March 2004 - java_dev (original) (raw)

04:05 pm - restoration_me - ArrayList question..... Hey everyone!! I found this community because I am in some desperate need of Java help.I'm writing a program that simulates a computer's allocation of memory through the algorithms of first fit, best fit, and worst fit. My proble though, lies within ArrayLists. I haven't used ArrayLists in awhile, and when I did, it was just for one simple Intro to Java program. So I know how to use the methods and such. However, what I am trying to do is put an object, Holes, that I have created in the ArrayList, and then invoke various methods of the Holes objects that I create. Going through the ArrayLists methods this is what I thought would work://Where each "size" is a different randomly genrated numberHoles hole1 = new Holes(size); Holes hole2 = new Holes(size);ArrayList mem = new ArrayList();mem.add(0,hole1);mem.add(1,hole2);//Where "getSize()" is a method in my Holes class that just returns the value//of the passed size of the holeSystem.out.println(mem.get(0).getSize());System.out.orintln(mem.get(1).getSize());So why will this not display the two different sizes? Researching the various ArrayList methods, it said that "get(int)" returns an object, so why can't I invoke its method?I hope that was clear enough! :)Cheers!RM