>Consider substituting two methods for this one. "getAsList" and
>"getAsSet" Then the caller can indicate which type is desired and always
>receive the correct type.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
> On Tue, 13 May 2008 11:37:53 -0700, Mark Space
> <markspace@sbc.global.net> wrote, quoted or indirectly quoted someone
[quoted text clipped - 6 lines]
> If it is always possible to get as List, why would you ever return
> anything else? You can always use a List as a Set.
String[] words = { "The", "thing", "about", "Sets",
"is", "that", "each", "item", "is", "present",
"once", "and", "once", "only." };
List<String> list = new ArrayList<String>();
Set<String> set = new HashSet<String>();
for (String w : words) {
list.add(w);
set.add(w);
}
assert list.size() == words.length;
assert set.size() == words.length; // BZZZZT!

Signature
Eric.Sosman@sun.com
Lew - 14 May 2008 00:41 GMT
>> On Tue, 13 May 2008 11:37:53 -0700, Mark Space
>> <markspace@sbc.global.net> wrote, quoted or indirectly quoted someone
[quoted text clipped - 18 lines]
> assert list.size() == words.length;
> assert set.size() == words.length; // BZZZZT!
Set <String> strangs = new ArrayList <String> (); // BZZZZT!

Signature
Lew
Roedy Green - 14 May 2008 09:22 GMT
>Set <String> strangs = new ArrayList <String> (); // BZZZZT!
Egg on beard. A List is a Collection, but it is NOT a Set.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com