Objects, Classes, and Interfaces |
Eight packages comprise the standard Java development environment.The Java Language Package
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 follow:The compiler automatically imports this package for you. No other packages are automatically imported.
- Object
- The grand-daddy of all classes--the class from which all others inherit. This class was covered previously in this lesson in The Object Class.
- Data Type Wrappers
- A collection of classes used to wrap variables of a primitive data type: Boolean, Character, Double, Float, Integer and Long. Each of these classes are subclasses of the abstract class Number.
- Strings
- Two classes that implement character data. The String and StringBuffer Classes is a thorough lesson on the use of both types of strings.
- System and Runtime
- These two classes provide let your programs use system resources. System provides a system-independent programming interface to system resources and Runtime gives you direct system-specific access to the runtime environment. Using System Resources describes both the System and Runtime classes and their methods.
- Threads
- The Thread, ThreadDeath and ThreadGroup classes implement the multi-threading capabilities so important to the Java language. The java.lang package also defines the Runnable interface. Runnable makes it convenient for Java class to be active without subclassing the Thread class. Through an example-oriented approach Threads of Control will teach you about Java threads.
- Classes
- The Class class provides a runtime description of a class and the ClassLoader class allows you to load classes into your program during runtime.
- Math
- A library of math routines and values such as pi.
- Exceptions, Errors and Throwable
- 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 Throwable class can be thrown. There are two main subclasses of Throwable: Exception and Error. Exceptions are a form of Throwable that "normal" programs may try to catch. Errors are used for more catastophic errors--normal programs should not catch errors. The java.lang package contains the Throwable, Exception and Error classes, and numerous subclasses of Exception and Error that represent specific problems. Handling Error Using Exceptions shows you how to use exceptions in your Java programs to handle errors.
- Processes
- Process objects represent the system process that is created when you use Runtime to execute system commands. The java.lang packages defines and implements the generic Process class.
The Java I/O Package
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.io
are covered fully in Input and Output Streams.The Java Utility Package
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.util
package also contains the Observer interface and Observable class which allow objects to notify one another when they change. Thejava.util
classes aren't covered separately in this tutorial although some examples use these classes.The Java Networking Package
Thejava.net
package 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 Security has several examples using these classes, including a client-server example and an example that uses datagrams.The Applet Package
This package contains the Applet class -- the class that you must subclass if you're writing an applet. Included in this package is the AudioClip interface which provides a very high level abstraction of audio. Writing Applets explains the ins and outs of developing your own applets.The Abstract Window Toolkit Packages
Three packages comprise the Abstract Window Toolkit:java.awt
,java.awt.image
, andjava.awt.peer
.Creating a User Interface covers all three of the AWT packages.
- AWT Package
- The
java.awt
package provides GUI elements used to get input from and display information to the user such as windows, buttons, scrollbars, and text items.- AWT Image Package
- The
java.awt.image
package 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.peer
package contains classes and interfaces that connect platform-independent AWT components to their platform-dependent implementation (such as Motif widgets or Microsoft Windows controls).
Objects, Classes, and Interfaces