Java Reference
In-Depth Information
APPENDIX
K
Important library classes
The Java platform includes a rich set of libraries that support a wide variety of programming
tasks.
In this Appendix, we briefly summarize details of some classes and interfaces from the most
important packages of the Java API. A competent Java programmer should be familiar with
most of these. This Appendix is only a summary, and it should be read in conjunction with the
full API documentation.
K.1
The java.lang package
Classes and interfaces in the java.lang package are fundamental to the Java language, as this
package is automatically imported implicitly into any class definition.
package java.lang-Summary of the most important classes
interface Comparable
Implementation of this interface allows comparison and ordering of objects
from the implementing class. Static utility methods such as Arrays.sort
and Collections.sort can then provide efficient sorting in such cases, for
instance.
class Math
Math is a class containing only static fields and methods. Values for the math-
ematical constants e and π are defined here, along with trigonometric functions
and others such as abs , min , max , and sqrt .
class Object
All classes have Object as a superclass at the root of their class hierarchy.
From it, all objects inherit default implementations for important methods such
as equals and toString . Other significant methods defined by this class are
clone and hashCode .
class String
Strings are an important feature of many applications, and they receive special
treatment in Java. Key methods of the String class are charAt , equals ,
indexOf , length , split , and substring . Strings are immutable objects,
so methods such as trim that appear to be mutators actually return a new
String object representing the result of the operation.
class StringBuilder
The StringBuilder class offers an efficient alternative to String when it is
required to build up a string from a number of components: e.g., via concatena-
tion. Its key methods are append , insert , and toString .
 
 
Search WWH ::




Custom Search