I want to make a new record in my enum list of usernames and passwords. I was going to make a method called register that would create a new record by calling the enum's constructor but when I call the constructor like this:
public void register(String usr, String pass) {
DB(usr, pass); //DB is the name of my enum
}
I get a error saying to create a new method. How am I able to call a constructor of my enum
Thanks for any help!
Enums are types with a closed set of instances. These instances are defined at class-design time (they are defined in the source code of the enum).
You cannot add enum instances at runtime. Enum constructors are private by language restrictions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With