Delphi like sets

V

Vojta

Please, how can I create Delphi like sets in Java?

In Delphi I could define set:

TAnimal = (aDog, aCat, aHorse, aSheep);
TAnimals = set of TAnimal;

And then for example:

Animals := [aDog, aCat];
if aDog in Animals then ...

Can I do sometling similar in Java? How?

Thank you a lot! Vojta
 
O

Oliver Wong

Vojta said:
Please, how can I create Delphi like sets in Java?

In Delphi I could define set:

TAnimal = (aDog, aCat, aHorse, aSheep);
TAnimals = set of TAnimal;

And then for example:

Animals := [aDog, aCat];
if aDog in Animals then ...

Can I do sometling similar in Java? How?

I don't know Delphi, and you didn't provide enough examples to guess at
the semantics, but you could probably do what you intend with either Java
1.5's enum, or the Set interface.

- Oliver
 
V

Vojta

Thank you Oliver! EnumSet it the thing I was looking for:)

Oliver Wong said:
Vojta said:
Please, how can I create Delphi like sets in Java?

In Delphi I could define set:

TAnimal = (aDog, aCat, aHorse, aSheep);
TAnimals = set of TAnimal;

And then for example:

Animals := [aDog, aCat];
if aDog in Animals then ...

Can I do sometling similar in Java? How?

I don't know Delphi, and you didn't provide enough examples to guess at
the semantics, but you could probably do what you intend with either Java
1.5's enum, or the Set interface.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,266
Messages
2,571,079
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top