Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: A Counter solution to Java 5 Enum in Java 1.4

Java 5 has a very good feature: enum. The enum keyword can be used to create C++ like enums.

Tutorial Details:

The enum created in Java 5 are a particular type of class whose instances are only those objects which are members of that enum. Each member of the enum is an instance of that enum class. The super class of all enum objects is java.lang.Enum and enums can not be extended. Java 5 also supports methods to be contained in an enum.
For example:
public enum MeasurementType {
Length, Mass, Time;
}

The following code works perfectly fine for the above enum and the output is shown below:
System.out.println(MeasurementType.Length instanceof MeasurementType);
System.out.println(MeasurementType.Length);
Output:
true
Length

Now, there are many situations where we need to use enums and the above stated features of enums but we can not use Java 5 features because of some requirements of the project (like many projects are created to run on JDK 1.3/1.4 because client environment does not support JDK 5 or some other reason like that). If such a case arises then many developers feel upset and devise their own method to tackle the problem at hand. Sometimes, there are situations where we have written a library using Java 5 features like enums but we need to use that library in a legacy project and port the whole code to Java 2. If we are using annotations, then we need to discard all the annotations and enums.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
A Counter solution to Java 5 Enum in Java 1.4

View Tutorial:
A Counter solution to Java 5 Enum in Java 1.4

Related Tutorials:

Java Q&A - Java Still Open
Java Q&A - Java Still Open
 
C#: A language alternative or just J--?, Part 2 - JavaWorld December 2000
C#: A language alternative or just J--?, Part 2 - JavaWorld December 2000
 
Pushlets: Send events from servlets to DHTML client browsers
Pushlets: Send events from servlets to DHTML client browsers
 
Java security evolution and concepts, Part 5
Java security evolution and concepts, Part 5
 
Trace your steps in Java 1.4
Trace your steps in Java 1.4
 
Java scripting languages: Which is right for you?
Java scripting languages: Which is right for you?
 
Business process automation made easy with Java, Part 1
Business process automation made easy with Java, Part 1
 
Interesting informations
Interesting informations
 
J2SE 1.4 breathes new life into the CORBA community, Part 3
J2SE 1.4 breathes new life into the CORBA community, Part 3
 
Sun boosts
Sun boosts enterprise Java
 
My kingdom for a good timer!
My kingdom for a good timer!
 
roots of constants classes
roots of constants classes
 
Overcome J2SE 1.3-1.4 incompatibilities
Overcome J2SE 1.3-1.4 incompatibilities
 
JXMLAppKit 2.0
JXMLAppKit is a pure Swing java framework for editing an XML document with multiple XML editors.
 
JView 2004 - J2EE Performance Management Software - Version 1.4
JView 2004 Enterprise Edition available now! JView 2004 is the leading J2EE Production Performance Monitor and Java Performance Tuning solution, providing precise real-time performance metrics to assist you in ensuring your performance requirements a
 
Java Testing and Design
Java Testing and Java Test and Design is the companion to any book on Java software development practices, techniques, and testing. Software developers, QA analysts and IT managers working in large corporate IT groups, software development companies, and
 
Creating Varargs in Java 1.5 Tiger
Creating Varargs in Java 1.5 Tiger In this excerpt from Chapter 5 of the book, Brett and David cover how to create and iterate over variable-length argument lists (better known as varargs), which will have you writing better, cleaner, more flexible code
 
HtmlCalendar bean ver. 1.4
Java bean allows you to generate Calendar for your HTML pages.
 
Network Programming with JavaTM 2 Platform, Standard Edition 1.4 (J2SETM)
This article provides an overview of the new features and enhancements in the Java 2 Platform, Standard Edition 1.4 (J2SE), and shows you how to use them effectively.
 
Just Forms PDF library
The JustFormsPDF library is a Java class library for filling or editing interactive PDF forms on-the-fly. Empower your applications with the industry-standard PDF forms technology using JustFormsPDF.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.