Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-x4r87 Total loading time: 0 Render date: 2024-04-28T08:13:50.395Z Has data issue: false hasContentIssue false

10 - Java utilities

Published online by Cambridge University Press:  08 January 2010

Clark S. Lindsey
Affiliation:
Space-H Services, Maryland
Johnny S. Tolliver
Affiliation:
Oak Ridge National Laboratory, Tennessee
Thomas Lindblad
Affiliation:
Royal Institute of Technology, Stockholm
Get access

Summary

Introduction

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.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Calvin Austin, J2SE 1.5 in a Nutshell, May 2005, http://java.sun.com/developer/technicalArticles/releases/j2se15/
Brett McLaughlin and David Flanagan, Java 1.5 Tiger, A Developer's Notebook, O'Reilly, 2004
Java 2 Platform, Standard Edition, API Specification, http://java.sun.com/j2se/1.5/docs/api/
Collections Framework, documentation at Sun Microsystems, http://java.sun.com/j2se/1.5.0/docs/guide/collections/
Regular Expressions – The Java Tutorial, Sun Microsystems, http://java.sun.com/docs/books/tutorial/extra/regex/
java.util.regex.Pattern specification, http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
Java Tutorial: Internationalizations, Sun Microsystems, http://java.sun.com/books/tutorial/il8n/index.html
Ronald Mak, The Java Programmer's Guide to Numerical Computing, Prentice Hall, 2003

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×