• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

enum within a class

 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we declare enum within a class.............

like

public class EnumTypeDeclarations
{
public void foo()
{
enum SimpleMeal {
BREAKFAST,LUNCH,DINNER
}
}
}
 
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

phil sohan wrote:can we declare enum within a class


What happened when you tried that?
Also, please UseCodeTags.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code actually asks a different question than your text: your code is asking whether or not you can define an enum within a *method*.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we declare enum within a class.............

like

public class EnumTypeDeclarations
{
public void foo()
{
enum SimpleMeal {
BREAKFAST,LUNCH,DINNER
}
}
}


I have seen this question somewhere in mock test of scjp1.6(not known where)
but i am really confused about it.........as of now i have seen enum is declared as seperate from class......
could you please tell whther its possible to declare it ornot,,,,,,
 
Devaka Cooray
Sheriff
Posts: 7135
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

phil sohan wrote:could you please tell whther its possible to declare it ornot,,,,,,


Devaka Cooray wrote:What happened when you tried that?

 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Devaka Cooray wrote:What happened when you tried that?



Agreed. It has been over 2 hours since the original post. Trying it yourself would have taken under a minute.

Henry
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And again, please note the difference between what you're asking in text and what your code is trying to do.

(I also think either your keyboard or keyboard driver is broken as you punctuation keys seem to repeat.)
 
reply
    Bookmark Topic Watch Topic
  • New Topic