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 O’Reilly online learning.

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