Hello,
I'm new to Java, can you please give an advice? In Delphi I could do this:
type
TFruit = (ftApple, ftOrange, ftBanana ...);
TFruits = set of TFruit;
Is it possible to the same in Java?
enum Fruit {APPLE, ORANGE, BANANA ...};
???
Thank you:) Vojta
Ranganath Kini - 11 Feb 2006 17:29 GMT
I haven't worked with Delphi, but Java certainly has set functionality
via java.util.Set interface and related implementations. For example,
Set has the following bulk functions which corelate to set operations:
Suppose s1 ans s2 are instances of java.util.Set, so...
s1.containsAll( s2 ) - Returns true if s2 is a subset of s1
s1.addAll( s2 ) - Transforms s1 into the union of s1 and s2
s1.retainAll( s2 ) - Transforms s1 into the intersection of s1 and s2
s1.removeAll( s2 ) - Transforms s1 into the (asymmetric) set difference
of s1 and s2, i.e. functuion retains all elements of s1 but removes all
elements of s2 from s1
For more information, consult the JavaDocs on the java.util.Set and the
related implementations at:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Set.html
Hope it helps!
Roedy Green - 11 Feb 2006 18:15 GMT
> TFruit = (ftApple, ftOrange, ftBanana ...);
> TFruits = set of TFruit;
>
>Is it possible to the same in Java?
see http://mindprod.com/jgloss/enum.html
It is more complex that Delphi, but it can do more powerful thing.s
See also Enumset.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Vojta - 11 Feb 2006 20:04 GMT
Thank you all a lot for your help! Vojta :o)
>> TFruit = (ftApple, ftOrange, ftBanana ...);
>> TFruits = set of TFruit;
[quoted text clipped - 4 lines]
> It is more complex that Delphi, but it can do more powerful thing.s
> See also Enumset.
Tris Orendorff - 13 Feb 2006 22:45 GMT
> Hello,
>
[quoted text clipped - 6 lines]
>
> Is it possible to the same in Java?
Yes, you can, with a little work and the java.util.BitSet class.