This is my first time studying Java I have a question while listening to the Java introduction lecture in programmers.
enum Gender{ MALE, FEMALE; }// define enumeration
Gender gender2;//<-enum class name object name;
gender2 =Gender.MALE;
gender2 =Gender.FEMALE;
//Use enumeration when it comes to
enum class name object name; He created and created an object called a gender I think they initialized the gender object with the constant defined by enum class In enum class, we don't use new enum class name object name; Is it a way to create an enum class object by declaring it as? How objects are created in the enum class I'm asking because I want to know.
java
As far as I know, each instance is created as much as the constant defined in the compilation stage, and these instances are contained in static variables defined as static final and can be used as a single ton form.
© 2024 OneMinuteCode. All rights reserved.