• Post Reply Bookmark Topic Watch Topic
  • New Topic

enum parameter in method declaration  RSS feed

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code sample does not compile saying modifier enum not allowed here.
Cant we pass enum constants in method call?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
enum (lower case 'e') is a keyword.
Enum (upper case 'E') is a class

Switch your code to use the class and things will work your for you.
Check out http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code tags correctly; don't double-click the Code button, because it will open and immediately close the code block.

Yes, you can pass enum constants to methods, but you shouldn't use the 'enum' keyword in the method declaration, just like you don't use the 'class' keyword in a method declaration.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!