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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.