I’m trying to understand when can I use the enums in Java.
So, let’s say I have three enums values :
enum Activity {
STUDENT, MECANICIAN, TEACHER
}
How can make use of this enum class in an existing Person class ? How is it persisted in a database?
class Person {
private String name;
private String age;
private String activity; // !!!
}
Thank you.
Just add the enum to
Person:One way to persist this field is to use an ORM such as Hibernate, for example:
would map the field to a text type field in the database.