13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

62Chapter 3An Experienced Programmer’s Introducti<strong>on</strong> to JavaTable 3.2 (C<strong>on</strong>tinued)Return typeMethodDescripti<strong>on</strong>Stringsubstring(int first, int last)Returns a string starting at positi<strong>on</strong> firstand up to, but not including, characterpositi<strong>on</strong> last. If last is greater than thelength of the String, or last is less thanfirst, it throws an IndexOutOfBoundsexcepti<strong>on</strong>.3.2.2.3 Other Classes: Reading JavadocJava comes with a huge collecti<strong>on</strong> of existing classes for you to use. The simplest<strong>on</strong>es are just wrappers for the primitive classes. There is an int primitive datatype, but Java provides an Integer class, so that you can have an integer as anobject. Similarly, there are classes for L<strong>on</strong>g, Float, Boolean, and so <strong>on</strong>. Suchclasses aren’t nearly as interesting as the myriad other classes that come withJava. These others provide objects for doing I/O, networking, 2D and 3Dgraphics, graphical user interfaces (GUIs), and distributed computing. Javaprovides ready-to-use classes for strings, math functi<strong>on</strong>s, and for special kindsof data structures like trees and sets and hash tables. There are classes to helpyou with the manipulati<strong>on</strong> of HTML, XML, and SQL, as well as classes forsound, music, and video. All these objects can be yours to use and enjoy if youjust learn the magic of reading Javadoc—<strong>on</strong>line documentati<strong>on</strong> for Java classes.The documentati<strong>on</strong> for all these classes is viewed with a Web browser. (In afollowing chapter we’ll describe how you can make Javadoc documents for theclasses that you write, too.)The <strong>on</strong>line versi<strong>on</strong> of the API documentati<strong>on</strong> can be found athttp://java.sun.com/j2se/1.4.2/docs/api/for Java 1.4.2. (Similarly, put 1.5.1 or whatever versi<strong>on</strong> you want at theappropriate 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 ourfigure, lists all the packages that are part of Java 2 Standard Editi<strong>on</strong> (J2SE).While there are many other packages of classes available for Java, these classesare the standard <strong>on</strong>es available without any other class libraries, with no

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!