Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

enum and data type  RSS feed

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data type of the constants is Day - they are instances of the enum.

You could have tried it out like this:
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meeta gaur wrote:private static final String day="SUNDAY";
here day is compile time constant, has String data type.

Exactly. And StringsAreBad (←click).

Winston
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jasper and Winston.
 
Campbell Ritchie
Sheriff
Posts: 53771
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jasper?
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Jasper?

Sorry, it's Jesper.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!