This is a quick reference for the Java keywords, classes, interfaces, fields, and methods presented in Java Resources. Primitive data types and operators are described separately. Refer to the JDK documentation for more information.

Keywords

catch: program execution is continued in a catch block if an exception is thrown in a corresponding try block.

class: defines a Java class. Syntax:

[access-modifier] class identifier [extends super-classes] [implements interfaces] {
	[field-and-method-definitions]
}

extends: extends a Java class.

false: boolean value representing "false."

final: defines a constant. Syntax:

[access-modifier] final data-type identifier = value;

finally: the finally block is executed whether or not an exception was thrown in a try block.

for: executes a loop body repeatedly until a condition is true. Syntax:

for(initial-statement; boolean-expression; update-statement)
	loop-body

if: creates a conditional code block. Syntax:

if(boolean-expression)
	code-executed-if-expression-is-true
[else
	code-executed-if-expression-is-false]

implements: implements a Java interface.

import: lets you access classes that have already been created, including those defined by the JDK. Syntax:

import package.class;
import package.*;

new operator: creates a new object.

null: value that represents "nothing."

private modifier: hides the class, method, or field from other classes.

public modifier: makes the class, method, or field visible to other classes.

return: exits a procedure or function, possibly returning the result of a calculation. Syntax:

return [value];

this: references the class it is contained in.

true: boolean value representing "true."

try: introduces a section that could throw exceptions. Syntax:

try { ... }
catch(exception-class identifier) { ... }
finally { ... }

void data type: defines a procedure.

while: executes a loop body repeatedly until a condition is true. Syntax:

while(boolean-expression)
	loop-body

Classes

Note: The package each class is found in is given in parentheses. The package java.lang is automatically included.

Applet: contains the information needed to create an applet (java.applet).

Color: holds information about a color; also defines color constants (java.awt).

Component: a visible object in Java (java.awt).

Date: contains date and time information (java.util).

Dimension: holds width and height information (java.awt).

Event: contains information about an event (java.awt).

Exception: contains information about an error (java.lang-exception).

Graphics: contains graphics routines that let you draw on a virtual "canvas" (java.awt).

Image: represents an image (java.awt).

InterruptedException: thrown when a thread is interrupted (java.lang-exception).

Point: holds the x- and y-coordinates of a two-dimensional point (java.awt).

String: holds a series of characters (java.lang).

Thread: manages a thread (java.lang).

Interfaces

Note: The package each interface is found in is given in parentheses.

Runnable: represents a thread (java.lang).

Fields

Note: The class each field belongs to is given in parentheses.

height: holds height information (Dimension).

length: holds the length of an array (arrays).

modifiers: (Event).

width: holds width information (Dimension).

x, y: holds the coordinates of a point (Point).

Methods

Note: The class each method belongs to is given in parentheses.

addPoint method: adds a point to a polygon (Polygon).

cos: returns the cosine of an angle (Math).

createImage: creates an Image object (Component).

destroy: override to perform clean-up operations (Applet).

drawImage: draws an Image (Graphics).

drawLine: draws a line (Graphics).

drawRect: draws a hollow rectangle (Graphics).

fillRect: draws a filled rectangle (Graphics).

getAppletInfo: override to return information about an applet (Applet).

getBackground: returns the background color of a component (Component).

getGraphics: returns a Graphics object linked to a component (Component).

getHours: returns the hour stored in a Date object (Date).

getMinutes: returns the minute stored in a Date object (Date).

getParameter: returns the value of an applet parameter (Applet).

getParameterInfo: override to return applet parameter information for an applet (Applet).

getSeconds: returns the second stored in a Date object (Date).

init: override to perform one-time initialization (Applet).

isAlive: determines if a thread is "alive"—running or suspended (Thread).

mouseDown, mouseDrag, mouseMove, mouseUp: called when the user presses a mouse button, drags the mouse, moves the mouse, and releases a mouse button, respectively (Component).

move: changes the coordinates of a Point object (Point).

paint: override to paint a component (Component).

parseInt: converts a String to an integer (Integer).

repaint: repaints a component (Component).

resume: resumes a thread after it has been suspended (Thread).

run: defines a thread's execution code (Runnable).

setColor: sets the current drawing color (Graphics).

sin: returns the sine of an angle (Math).

size: returns the size of a component (Component).

sleep: suspends a thread for a time interval (Thread).

start: override to respond to the Start stage of the life cycle; called after Initialization and also each time the applet is restarted (Applet).

start: starts the execution of a thread; calls run() (Thread).

stop: override to respond to the Stop stage of the life cycle; called before Destroy and also each time the applet is stopped (Applet).

stop: stops a thread (Thread).

suspend: suspends a thread (Thread).

update: prepares a component for painting; override to implement drawing buffers (Component).


1