Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enum methods

 
Jack Bento
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Please help me understand the difference between these 2 methods. How would I call them? Why is the first one enclosed in curlys?

Thanks!

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you able to compile this code?
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, let me try to make your code compilable (and a little more relevant):



SCARY overrides the spice() method, that's why it is declared inline (in curlys).
'new' is not suitable for enums in general (not to mention that is syntactically wrong.
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the above code you can compile and run successfully.
 
Jack Bento
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


does not compile?
 
Jack Bento
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I get it now. The first method belongs to scary. Thanks for helping me.
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Bento wrote:

does not compile?


dint get you??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic