aspose file tools*
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 Spring in Action this week in the Spring 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: 14272
    
  21

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 8 API documentation
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8012
    
  22

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?
Articles 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: 39436
    
  28
Jasper?
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Campbell Ritchie wrote:Jasper?

Sorry, it's Jesper.
 
Don't get me started about those stupid light bulbs.
 
subject: enum and data type