12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

installing ptplot & java developer’s kit packages 565TABLE B.1Some of Java’s Packages and the Classes They ContainJava PackageClasses forjava.langBasic elements of the Java languagejava.utiljava.awtjava.appletjava.beansjava.ioUtilities; random-number generators, date, time, and so onAbstract Windowing Toolkit; creating graphical interfacesCreating applets and interacting with browsersCreating reusable software componentsData input and outputB.2 Using Classes and PackagesMost of the programs we give as examples contain a single class in a file with a.java or .class extension. That class contains a main method and possibly someother methods. Just as we encourage you to modify old programs rather than writeall programs from scratch, so we encourage you to include in your new programsmethods that you and others have already written and debugged. Java contains alarge number of libraries consisting of collections of methods for various purposes,and you should think of these libraries as toolboxes from which you can extractindividual tools needed for your programs. In fact, the object-oriented approachof Java is specifically designed to make the reuse of components easier andsafer.B.2.1 Including PackagesA collection of related methods is called a class, and a broader collection, a library(such as the Math library). In strict Java naming convention, each method wouldbe in a class file, and the libraries would be called packages. In general, there are twotypes of packages: the standard Java packages that constitute the Java language,and user-defined packages that extend standard Java. The PtPlot package is anexample of a user-defined package. Some of the standard Java packages are givenin Table B.1.Because these Java packages contain hundreds or thousands of classes, someorganization is necessary to keep track of what each method does. Java does thiswith a hierarchical directory structure in which there are parent packages containingsubpackages, with the subpackages containing more subpackages or variousclasses. To make the name of each class unique, it is preceded by the names of−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 565

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

Saved successfully!

Ooh no, something went wrong!