• 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

SCJP 5: Q on enums

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have some questions regarding to enums, please shed some light

1) In the API document, the java.lang.Enum was declared as Class Enum<E extends Enum<E>>, but isn't it a recursive declaration? what does it mean then? "The type parameter should be a type extends Enum<E> in which E is itself?" -- just too complicated for me.

2) Where is the static values() method declared? I didn't find it in the Enum class, however.

Thanks

(SCJP 5 prefix added to topic title)
[ January 12, 2005: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enums have 2 implictly defined methods

public static E[] values();

public static E valueOf(String name);
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the topic of enums, I noticed that Enum.valueOf is documented to throw NullPointerException if enumType is null, however, an IllegalArgumentException is thrown, at least by the Sun 1.5.0 VM on win32.

I'd bother raising a bug, or checking if it already exists, if it wasn't such a mission to use the bug parade.
 
reply
    Bookmark Topic Watch Topic
  • New Topic