|
|
Objects, Classes, and Interfaces |
Eight packages comprise the standard Java development environment.The Java Language Package (
notes)
The Java language package, also known asjava.lang, contains classes that are core to the Java language. The classes in this package are grouped as follows:The compiler automatically imports this package for you. No other packages are automatically imported.
Object- The granddaddy of all classes--the class from which all others inherit. This class was covered previously in this lesson in The
ObjectClass.- Data Type Wrappers
- A collection of classes used to wrap variables of a primitive data type:
Boolean,Character,Double,Float,IntegerandLong.- Strings
- Two classes that implement character data. The String and StringBuffer Classes
is a thorough lesson on the use of both types of strings.
SystemandRuntime- These two classes provide let your programs use system resources.
Systemprovides a system-independent programming interface to system resources andRuntimegives you direct system-specific access to the runtime environment. Using System Resourcesdescribes both the
SystemandRuntimeclasses and their methods.- Threads
- The
Thread,ThreadDeathandThreadGroupclasses implement the multi-threading capabilities so important to the Java language. The java.lang package also defines theRunnableinterface.Runnablemakes it convenient for Java class to be active without subclassing theThreadclass. Through an example-oriented approach Threads of Controlwill teach you about Java threads.
- Classes
- The
Classclass provides a runtime description of a class and theClassLoaderclass allows you to load classes into your program during runtime.Math- The
Mathclass provides a library of math routines and values such as pi.Exception,Error, andThrowable- When an error occurs in a Java program, the program throws an object which indicates what the problem was and the state of the interpreter when the error occurred. Only objects that derive from the
Throwableclass can be thrown. There are two main subclasses ofThrowable:ExceptionandError. Exceptions are a form ofThrowablethat "normal" programs may try to catch. Errors are used for more catastophic errors--normal programs should not catch errors. Thejava.langpackage contains theThrowable,Exception, andErrorclasses, and numerous subclasses ofExceptionandErrorthat represent specific problems. Handling Error Using Exceptionsshows you how to use exceptions in your Java programs to handle errors.
ProcessProcessobjects represent the system process that is created when you useRuntimeto execute system commands. Thejava.langpackages defines and implements the genericProcessclass.The Java I/O Package (
notes)
The Java I/O Package (java.io) provides a set of input and output streams used to read and write data to files or other input and output sources. The classes and interfaces defined injava.ioare covered fully in Input and Output Streams.
The Java Utility Package (
notes)
This Java package,java.util, contains a collection of utility classes. Among them are several generic data structures (Dictionary,Stack,Vector,Hashtable) a useful object for tokenizing a string and another for manipulating calendar dates. Thejava.utilpackage also contains theObserverinterface andObservableclass, which allow objects to notify one another when they change. Thejava.utilclasses aren't covered separately in this tutorial although some examples use these classes.The Java Networking Package (
notes)
Thejava.netpackage contains classes and interface definitions that implement various networking capabilities. The classes in this package include a class that implement a URL, a connection to a URL, a socket connection, and a datagram packet. You can use these classes to implement client-server applications and other networking communication applications. Custom Networking and Securityhas several examples using these classes, including a client-server example and an example that uses datagrams.
The Applet Package (
notes)
This package contains theAppletclass -- the class that you must subclass if you're writing an applet. Included in this package is theAudioClipinterface which provides a very high level abstraction of audio. Writing Appletsexplains the ins and outs of developing your own applets.
The Abstract Window Toolkit Packages (
notes)
Three packages comprise the Abstract Window Toolkit:java.awt,java.awt.image, andjava.awt.peer.Creating a User Interface
- AWT Package
- The
java.awtpackage provides graphical user interface (GUI) elements that are used to get input from and display information to the user. These elements include windows, buttons, scrollbars, and text items.- AWT Image Package
- The
java.awt.imagepackage contains classes and interfaces for managing image data, such as setting the color model, cropping, color filtering, setting pixel values, and grabbing snapshots of the screen.- AWT Peer Package
- The
java.awt.peerpackage contains classes and interfaces that connect platform-independent AWT components to their platform-dependent implementation (such as Motif widgets or Microsoft Windows controls).covers all three of the AWT packages.
![]()
Objects, Classes, and Interfaces