This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes enum parameter in method declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "enum parameter in method declaration" Watch "enum parameter in method declaration" New topic
Author

enum parameter in method declaration

MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188


The above code sample does not compile saying modifier enum not allowed here.
Cant we pass enum constants in method call?


I am slow but sure
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8439

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


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12928
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: enum parameter in method declaration
 
Similar Threads
Enum Issue
Declaring Enums in a class
retrieve enumeration datatype into jsp
abstract method within an enum ?