KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > Enum

java.lang
Class Enum<E extends Enum<E>>

java.lang.Object
  extended by java.lang.Enum<E>
All Implemented Interfaces:
Serializable, Comparable<E>
See Also:
Top Examples

protected final Object clone()
                      throws CloneNotSupportedException
See Also:
Cloneable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int compareTo(E o)
See Also:
Comparable, compareTo
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected Enum(String name,
               int ordinal)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1322]Define enum and print its values
By Anonymous on 2005/08/12 18:48:31  Rate
package com.test.jdk15; 
  
  
 import java.lang.instrument.Instrumentation; 
 import java.util.ArrayList; 
 import java.util.List; 
  
  
 public class TestClass 
  {  
     enum Season  {  WINTER, SPRING, SUMMER, FALL  } ; 
     enum Color  {  RED, BLUE, WHITE } ; 
     
     public void run (  )  
      {  
       Instrumentation instrumentation = null; 
       List < String >  list = new ArrayList < String >  (  ) ; 
       list.add ( "Hello World" ) ; 
       list.add ( "Hello World1" ) ; 
       list.add ( "Hello World2" ) ; 
       String value = list.get ( 2 ) ; 
       
       for  ( Season seasons : Season.values (  )  )   {  
         System.out.println ( seasons.toString (  )  ) ;      
        }  
       print ( list ) ;      
         
      }  
     
     void print ( List < String >  c )   {  
         for  ( String t : c )  
             System.out.println ( t.toUpperCase (  )  ) ; 
      }  
  
  
     /** 
      * @param args 
      */
 
     public static void main ( String [  ]  args )  
      {  
         new TestClass (  ) .run (  ) ; 
      }  
  
  
  } 


public final boolean equals(Object other)
See Also:
Hashtable, Object.hashCode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final Class<E> getDeclaringClass()
See Also:
Object.getClass()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String name()
See Also:
toString()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int ordinal()
See Also:
EnumMap, EnumSet
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static <T extends Enum<T>> T valueOf(Class<T> enumType,
                                            String name)
See Also:
NullPointerException, IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags