An Introduction to Scientific and Technical Computing with Java
By Clark S. Lindsey
By Johnny S. Tolliver
By Thomas Lindblad
Publisher: Cambridge University Press
Print Publication Year: 2005
Online Publication Date:January 2010
Chapter DOI: http://dx.doi.org/10.1017/CBO9780511615948.011
Any language should come with a well-stocked toolbox of utilities to ensure programming efficiency and convenience. The Java core language, in fact, includes a large package named, quite sensibly, java.util that holds classes to handle arrays, hash tables, time keeping, and other common tasks. In this chapter, we focus mostly on this package but also discuss some handy tools in other packages such as String and StringBuffer in java.lang and StringBuilder and enum, that were added to java.lang for J2SE 5.0 [1, 2]. We also discuss the Collections Framework and the new Generics feature of J2SE 5.0.
We also look at classes and techniques for handling numbers at two extremes. For bits we have the java.util.BitSet class. For arbitrarily large numbers and for those that with very long decimal fractions we have the java.math. BigInteger and java.math.BigDecimal classes.
We can only briefly describe here the general workings of these classes, many of which contain a great number of methods. See the class descriptions in the Java 2 API Specifications for the full details.
The java.util Package
The package java.util has been part of the core language since Java 1.0. However, several classes have been added in subsequent versions. As the name suggests, the classes in this package serve a number of useful utility purposes, and we discuss several of them in this chapter.