Enum types

Before describing the enum type, let's look at one of the use cases as the motivation for having such a type. Let's assume we would like to create a class that describes TheBlows family:

public class TheBlows {  private String name, relation, hobby = "biking";  private int age;  public TheBlows(String name, String relation, int age) {    this.name = name;    this.relation = relation;    this.age = age;  }  public String getName() { return name; }   public String getRelation() { return relation; }  public int getAge() { return age; }  public String getHobby() { return hobby; }  public void setHobby(String hobby) { this.hobby = hobby; }}

We have set the default hobby as biking and will allow to change it later, but other properties have to be set ...

Get Introduction to Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.