This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes enum and data type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "enum and data type" Watch "enum and data type" New topic
Author

enum and data type

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305



private static final String day="SUNDAY";

here day is compile time constant, has String data type. so in enum class what is data type of all constants ?


My one regret in life is that I am not someone else.
- Woody Allen
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

The data type of the constants is Day - they are instances of the enum.

You could have tried it out like this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7081
    
  16

meeta gaur wrote:private static final String day="SUNDAY";
here day is compile time constant, has String data type.

Exactly. And StringsAreBad (←click).

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Thank you Jasper and Winston.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36575
    
  16
Jasper?
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Campbell Ritchie wrote:Jasper?

Sorry, it's Jesper.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enum and data type
 
Similar Threads
Why Enum type are not extended futher
Enum question
enum is Java keyword ?
Where do enums live?
ENUM problem