You are confused between several different classes.
enum
Enumeration
Iterator
An enum
is an enumerated constant, i.e. a constant that can take several defined values such as
public enum Gender {
MALE,
FEMALE;
}
It is designed to provide type safety.
An Enumeration
is a now deprecated part of the Collection
s API - forget about this. It is superseded by Iterator
.
An Iterator
is an implementation of the Iterator Pattern as described by the Gang of Four.
For why to use an Iterator
rather than a Collection
maybe my answer here will help.
As for enums of people in the format of name(String description, int age), and that's how he defined his constructor and he had get and set methods. This is a big no-no.
An enum
should be a constant so should not have setter
methods. An enum
is a set of defined values like in my example above.
If you want a Collection
of people
then a Person
class in a Collection<Person>
would be the correct solution.
So, in summary. Use an enum
for constant values; use a Collection
for, well, collections of things. And do not use an Enumeration
- forget it exists at all.