| Author |
what is Enum
|
jacob deiter
Ranch Hand
Joined: Apr 02, 2008
Posts: 576
|
|
Hi all CAn anyone explain about "Enum" in ?.I read some some article but i could not get the correct point. 2) I like to have a varialbe which contain 4 or 5 element ,at runtime i will give value for this variable,For example variable loom ,it has elements color,manufacture,....).PLease explain ,how can i create variable which has many elements
|
 |
f. nikita thomas
Ranch Hand
Joined: Mar 02, 2008
Posts: 87
|
|
if you look closely it's kinda like a class! it has fields and methods to change behavior. like everything else in java Enum's are zero indexed so ... which could come in pretty handy when you're trying to index a data structure like and array or vector. finally if you look at the PaperCurrency Enum we actually can add a value to the element; in this case the primitive (int). the field: refers to the value stored in each element ie One(1), Five(5), etc. the accessor method getValue() returns these when called on the appropriate element. since Enums are object you can test for uniqueness with instanceof. i hope this helps a little. [ April 15, 2008: Message edited by: f. nikita thomas ]
|
Imagination is more important than knowledge "Albert Einstein"
|
 |
Rodrigo Lopes
Ranch Hand
Joined: Feb 29, 2008
Posts: 118
|
|
Take a look: http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html
|
 |
Anubhav Anand
Ranch Hand
Joined: May 18, 2007
Posts: 341
|
|
An enum is a type whose fields consist of a fixed set of constants. Enums were introduced in Java 5.0. If you are using a version lower than JDK 1.5 then you won't be able to harness the power of enums. Please visit this link for details on enums.
|
 |
 |
|
|
subject: what is Enum
|
|
|