Look at lazyList(): 
http://jakarta.apache.org/commons/collections/api/org/apache/commons/collections/ListUtils.html

-----Original Message-----
From: Jian Dai [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 3:40 PM
To: Struts Users Mailing List
Subject: RE: ArrayList problem


If you just want to add a new object as the last one. You can simply
call the add(Object o), it will automatically add as last one and the
size automatically increment by 1.

If need to add it in a special place. Then there is no simple way as
far as I know. As you know, Arraylist basically is an array, it is
not easy to insert an object in the middle of array. You have to pay
the same cost here.

Good luck.

Jack

-----Original Message-----
From: Rajat Pandit [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 12:22 AM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: ArrayList problem


hello jack,
thanks for the input, so how do i rectify that (which amounts to spoon
feeding) but now iam shameless :(.
HELP!!!!

Jian Dai wrote:
> The ArrayList.ensureCapacity(int min) does not change the size. So even
> the minimum capacity of this array increase, this size of this array still
> keeps same. if the size happens to be less than the minicapacity (in your
> case), the error will occurs. If you check the size value, I bet it will
> less than index+1 in your case.
>
> Jack
>
> -----Original Message-----
> From: Rajat Pandit [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 04, 2003 8:45 PM
> To: Struts Users Mailing List; [EMAIL PROTECTED]
> Subject: ArrayList problem
>
>
> hello,
> i am stuck in a simple piece of code, for which i have spent the last
> 2hrs and i seriously dont know what is wrong with this.
> this is the setter method for an indexed property that i am using. sinci
> i dont know how the size required i am checking if the index is >= the
> size and in that case i am increasing the size() by idx + 1.
>
>      public void setName(int idx, String value) {
>          System.err.println("----------------");
>          System.err.println("In the setName method");
>          System.err.println("Idx: " + idx + ", Value: " + value);
>          System.err.println("----------------");
>          if (idx >= name.size()) {
>              this.name.ensureCapacity((idx + 1));
>          }
>
>          this.name.add(idx,value);
>
>      }
>
>
>
> in a seperate problem, only idx (in the right order 0,1,2,3,4) works fine.
>
> this particular method works fine for idx = 2 and anything bigger than
> that gives errror.
>
> aused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 1
>       at java.util.ArrayList.add(ArrayList.java:367)
>       at
>
com.hedging.admin.productmanagement.StateForm.setStartValue(StateForm.java:9
> 1)
>       ... 43 more
> i would be reaslly thankful in someone could suggest me something.
>
>
> --
>
>
> Rajat Pandit | [EMAIL PROTECTED]
> +91 612 3117606
> [ Developer and Part Time Human Being]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

--


Rajat Pandit | [EMAIL PROTECTED]
+91 612 3117606
[ Developer and Part Time Human Being]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to