Before you start
Commons Lang is a component of Apache Commons, a macro project whose many subprojects relate to various aspects of software development in the Java™ language. Commons Lang extends the standard java.lang API with string-manipulation methods, basic numerical methods, object reflection, creation and serialization, and System properties. It also contains an inheritable enum type, support for multiple types of nested Exceptions, enhancements to java.util.Date, and utilities that help with building methods such as hashCode, toString, and equals. I've found Commons Lang to be helpful across a wide variety of application verticals. By using Commons Lang, you'll end up writing less code, which lets you deliver production-ready software faster and with fewer defects. This tutorial guides you step-by-step through the fundamental concepts of using a few different Commons Lang classes and leveraging their code so that you don't have to write so much of it yourself.
You'll learn how to:
- Implement object contracts such as
equalsandhashCode. - Verify their proper functionality.
- Implement the
Comparableinterface'scompareTomethod.
When you are done with the tutorial, you will understand the benefits of the Commons Lang library and learn how to write less code.
To get the most from this tutorial, you should be familiar with Java syntax and the basic concepts of object-oriented development on the Java platform. You should be familiar with refactoring and normal unit testing as well.
To follow along and try out the code for this tutorial, you need:
- A working installation of either:
- The current release of the Commons Lang project (2.4 as of this writing). After you download and unpack the distribution, include commons-lang-2.4.jar in your classpath.
The recommended system configuration for this tutorial is:
- A system supporting either the Sun JDK 1.5.0_09 (or later) or the IBM JDK 1.5.0 SR3 with at least 500MB of main memory.
- At least 20MB of disk space to install the software components and examples covered.
The instructions and examples in the tutorial are based on a Microsoft® Windows® operating system. All the tools covered in the tutorial also work on Linux® and UNIX® systems.


