Is it just me or does the NSArray.subList() implementation return too many elements.

I have the following code:

Object[] list = {"1", "2", "3", "4", "5"};
ArrayList  list1 = new ArrayList(Arrays.asList(list));
NSArray list2 = new NSArray(list);

System.out.println(list1);
System.out.println(list2);
System.out.println(list1.subList(0, 1));
System.out.println(list2.subList(0, 1));

and it produces:

[1, 2, 3, 4, 5]
("1", "2", "3", "4", "5")
[1]
("1", "2")


The sun definition of List.subList is:
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

The NSArray behaviour is "toIndex inclusive", which is wrong.

Can someone else confirm this is the case? I would otherwise just use subArrayWithRange, but the code I am working with needs to use the List collection interface.

--
Seeya...Q

Quinton Dolan - [EMAIL PROTECTED]
Gold Coast, QLD, Australia
Ph: +61 419 729 806


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to