Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Enum Problem  RSS feed

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why cannot new constants of the
enum type MachineState be created ?

 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot instantiate enums on your own. enums only contain the constants declared inside of them. So you can do
Machine ob = Machine.ac
But you cannot do
Machine ob = new Machine();
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:You cannot instantiate enums on your own. enums only contain the constants declared inside of them. So you can do
Machine ob = Machine.ac
But you cannot do
Machine ob = new Machine();


That's the intention of the enum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!