Java Reference
In-Depth Information
Table 3.2 (Continued)
Return type
Method
Description
substring(int first, int last)
Returns a string starting at position first
and up to, but not including, character
position last . If last is greater than the
length of the String , or last is less than
first , it throws an IndexOutOfBounds
exception.
String
3.2.2.3
Java comes with a huge collection of existing classes for you to use. The simplest
ones are just wrappers for the primitive classes. There is an int primitive data
type, but Java provides an Integer class, so that you can have an integer as an
object. Similarly, there are classes for Long , Float , Boolean , and so on. Such
classes aren't nearly as interesting as the myriad other classes that come with
Java. These others provide objects for doing I/O, networking, 2D and 3D
graphics, graphical user interfaces (GUIs), and distributed computing. Java
provides ready-to-use classes for strings, math functions, and for special kinds
of data structures like trees and sets and hash tables. There are classes to help
you with the manipulation of HTML, XML, and SQL, as well as classes for
sound, music, and video. All these objects can be yours to use and enjoy if you
just learn the magic of reading Javadoc —online documentation for Java classes.
The documentation for all these classes is viewed with a Web browser. (In a
following chapter we'll describe how you can make Javadoc documents for the
classes that you write, too.)
The online version of the API documentation can be found at
Other Classes: Reading Javadoc
http://java.sun.com/j2se/1.4.2/docs/api/
for Java 1.4.2. (Similarly, put 1.5.1 or whatever version you want at the
appropriate place in the URL.) When displayed, it shows a three-frame page,
as seen in Figure 3.1, except that we've overlaid the image with three labels:
A, B, and C.
The upper left frame of the Javadoc display, the area labeled with A in our
figure, lists all the packages that are part of Java 2 Standard Edition (J2SE).
While there are many other packages of classes available for Java, these classes
are the standard ones available without any other class libraries, with no
Search WWH ::




Custom Search