Java
The Java API
Java 1.4 consists of over 2700 pre-written classes organized in the Application Programmer Interface (API). The following is a brief list of some of the most commonly used Java classes, organized by package. The complete API can be found at http://java.sun.com/j2se/1.4.1/docs/api.
Java.Lang
Consists of the Java classes that form the basis of the language; classes representing the elements Java needs to function such as Object, Method, Class, System; and wrappers for the primitive types. The functionality of most of these methods is generally encapsulated by the Java VM.
-
Object is at the root of the class hierarchy. Its methods serve to manipulate objects as they are stored in memory.
-
Math and StrictMath contain static methods for performing basic mathematical functions. The two classes are very similar, but StrictMath is used primarily in cryptographic applications needing platform-independent results.
-
Boolean, Character, Double, Float, and Integer are wrapper classes, used to treat primitive types ttas objects. They contain methods for conversions between Strings and primitive types or wrappers.
-
System maintains the standard input, output, and error streams; the clock; and the system properties. System also has a method that copies part of an array.
-
String and StringBuffer represent character strings. A String is immutable; a StringBuffer is not.
-
Thread represents a thread of execution. Java is a multithreaded language allowing simultaneous execution of code segments.
Java.10
Contains classes that allow Java to receive input and output from the user and to communicate with the filesystem.
-
File represents a file or a directory pathname.
-
InputStream represents a stream of incoming byte data. It is an abstract class, overridden by such classes as FileInputStream, FilterInputStream, ObjectInputStream, and PipedInputStream. FilterInputStream is used with an instantiation of a subclass such as BufferedInputStream.
-
OutputStream represents a stream of outgoing byte data. It is an abstract class, overridden by such classes as FileOutputStream, FilterOutputStream, ObjectOutputStream, and PipedOutputStream. FilterOutputStream is used with an instantiation of a subclass such as BufferedOutputStream.
-
Reader is an object that reads character streams. It is an abstract class, overridden by such classestt as BufferedReader, FileReader, PipedReader, and StringReader.
-
Writer is an object that writes character streams. It is an abstract class, overridden by such classes as BufferedWriter, FileWriter, PipedWriter, and StringWriter.
Java.Util
Contains utilities such as basic data structures; classes representing times, dates and locations; fundamental event classes; and miscellaneous utilities.
-
Vector and ArrayList are implementations of growable arrays. Unlike ArrayList, Vector methods are synchronized, making Vector inefficient but thread-safe. ArrayList methods are not synchronized.
-
Hashtable and Hashmap are data structures that map keys to values.
-
Stack represents a stack of objects.
-
LinkedList and Iterator are used to implement a linked list data structure. The structure is stored in the LinkedList and returned by the Iterator.
-
Date represents a specific time, precise to the nearest millisecond.
-
GregorianCalendar represents a standard calendar.
-
EventObject is the root class for all events (see java.awt.event).
-
Timer allows applications to schedule execution of commands.
-
StringTokenizer breaks a string into tokens, pieces marked by certain delimiters (generally white space or punctuation marks, but the specific delimiters can be given as parameters to the constructor).
-
Random represents a pseudorandom number generator. Depending on the method called, it returns either a “random” byte array, integer, decimal, or Gaussian distributed value between zero and one and with standard deviation of one.
Java.AWT
Contains the classes of the Abstract WindowingToolkit, which is used to create graphics and images. Many of the classes in java.awt have been updated in Swing.
-
Graphics is the base class for all graphical components. It contains methods for drawing shapes and Strings on a Canvas object. The Graphics2D class extends the Graphics class with several enhancements.
-
Component represents a graphic object that the user can interact with, such as a Button, Label, or Scrollbar; all of which extend Component.
-
Container is a type of Component that can hold other components. It contains methods for adding and placing new components into a container.
-
Window is a top-level window with no borders or menu bar.
-
Point is a location in the coordinate plane, specified to the nearest integer.
-
Polygon represents a polygon, a closed region in the coordinate plane.
-
Color has a list of pre-defined fields that represent various colors, as well as methods for creating a new color from an existing Color or from three ints between 0 and 255 representing red, blue, and green components.
Java.AWT.Event
Contains classes representing events, and interfaces that model listeners. Events are generated whenever something happens in the program or with the computer’s peripherals; listeners have a programmer-defined response to events. Events themselves have fields that define such attributes as the location and time of the events and the name of the component that generated the event.
-
MouseEvent is an object generated whenever the mouse moves or whenever the mouse button is pressed. The MouseListener and MouseMotionListener interfaces respond to MouseEvents.
-
ActionEvent is an object generated by components such as Buttons or CheckBoxes. The ActionListener interface responds to ActionEvents.
-
KeyEvent is an object generated whenever a keystroke occurs. The KeyListener responds to KeyEvents.
-
WindowEvent is an object generated whenever the status of a window changes (e.g., when a window is closed or maximized). The WindowListener interface responds to WindowEvents.
Java.Util.RegEx
Contains the Pattern and Matcher classes and is used for parsing regular expressions.
-
Pattern represents a regular expression.
-
Matcher is an object that can find and replace a Pattern in a given character sequence.
JavaX.Swing
Describes the Java Foundation Class “Swing,” which is used to make Graphical User Interfaces (GUIs) and is similar to the java.awt package but more comprehensive. The primary difference between Swing and AWT is that Swing is implemented without native code, meaning that it is more portable than AWT. For more information on Swing. See http://java.sun.com/docs/books/tutorial/uiswing.
-
JComponent is analagous to an AWT Component. It is the base class for any of Swing’s graphical objects, such as JButton, JFrame, or JLabel.
-
JPanel and JFrame are containers, which are JComponents that can hold other JComponents.
-
ImageIcon turns an Image object into an Icon. Icon is an interface of the javax.swing package.
-
BoxLayout and OverlayLayout are layout managers, which determine the placement of components in a GUI. Choose a layout manager with the component’s setLayout(LayoutManager) method.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, inc. in the United States and other countries. SparkNotes is independent of Sun Microsystems, inc.
The Java API
