Java Reference
In-Depth Information
The String classrepresentsastringasasequenceofcharacters.Becauseinstances
ofthisclassareimmutable,Javaprovides StringBuffer and StringBuilder for
buildingastringmoreefficiently.Theformerclasscanbeusedinamultithreadedcon-
text, whereas the latter class is more performant.
The System classprovidesaccesstostandardinput,standardoutput,standarderror,
and other system-oriented resources. For example, System provides the array-
copy() method as the fastest portable way to copy one array to another.
Javasupportsthreadsviaitslow-levelThreadingAPI.ThisAPIconsistsofoneinter-
face ( Runnable ) and four classes ( Thread , ThreadGroup , ThreadLocal , and
InheritableThreadLocal ).
Throughout its execution, each thread is isolated from other threads because it has
beengivenitsownmethod-callstack.However,threadscanstillinterferewitheachoth-
erwhentheyaccessandmanipulateshareddata.Thisinterferencecancorrupttheshared
data, and this corruption can cause an application to fail. Java provides a thread-syn-
chronization mechanism to prevent this interference.
Money must never be represented by floating-point and double precision floating-
pointvariablesbecausenotallmonetaryvaluescanberepresentedexactly.Incontrast,
the BigDecimal class lets you accurately represent and manipulate these values.
BigDecimal reliesonthe BigInteger classforrepresentingitsunscaledvalue.
A BigInteger instancedescribesanintegervaluethatcanbeofarbitrarylength(sub-
ject to the limits of the JVM's memory).
This chapter briefly referred to the Collections Framework while introducing the
Primitive Type Wrapper Class API. Chapter 5 introduces you to this broad utility API
for collecting objects.
Search WWH ::




Custom Search