Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Java Tip 5: Java constants

Create constants that have the benefits of <br> using the C preprocessor's facilities

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 2 of 2

I've put all of these fun things together in a couple of simple Java applications. Constants (http://www.javaworld.com/javatips/javatip5/Constants.java) implements the interface and uses the constants directly while Constants2 (http://www.javaworld.com/javatips/javatip5/Constants2.java) uses fully qualified names to access the constants.

About the author

John D. Mitchell is yet another UC-Berkeley Computer Science graduate weaned on caffeine, sugar, and way too little sleep. He spent three years toiling on PDA software at Geoworks for stock that is actually worth more than wallpaper. He bailed out of his day job after the first public release of Java to develop applets and a Java compiler. He funds his Java addiction by writing compilers, Tcl/Tk, Perl, C++, and Java systems. His copious spare time is consumed by moderating the comp.lang.tcl.announce newsgroup and writing an awesome Java book.
  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (3)
Login
Forgot your account info?

Constants Interface Anti PatternBy Anonymous on October 6, 2009, 8:41 amHaving an interface with all the constants and then making your classes implement that interface is considered an anti pattern nowadays (perhaps it wasn't in 1996)....

Reply | Read entire comment

:)By Anonymous on July 22, 2009, 11:24 amNicely put.

Reply | Read entire comment

:OBy Anonymous on November 30, 2008, 4:50 pmvery good"!

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources