Alternative to enum in Java 1.4 -


Because Java 1.4 does not have enums, I am doing something like this:

  Some class of public class {public fixed int SOME_VALUE_1 = 0; Public static int SOME_VALUE_2 = 1; Public static int SOME_VALUE_3 = 2; Some value of public void (value some value) {// something}}  

The recipient's caller should pass those 3 values, but he can pass any other int If it were an enum then the caller could pass only a valid value.

Should some invalid evacuation be thrown?

What are the good alternatives for Java 5?

The best used in the pre-1.5 is best described in the book. Although there are some limitations, especially when you are working on different classloaders, serialization and so on.

You can also look at the Apache Commons Lang project and John wrote the eponymous en class. It is the implementation of this method and helps in building your own energy.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -