Chapter 32

Package java.lang


CONTENTS


The Java language package, also known as java.lang, provides the core classes that make up the Java programming environment. The language package includes classes representing numbers, strings, and objects, as well as classes for handling compilation, the runtime environment, security, and threaded programming. The java.lang package is imported automatically into every Java program. Table 32.1 shows the contents of the java.lang package, and Figure 32.1 presents the hierarchy graphically.

Figure 32.1: Contents of package java.lang.

Table 32.1. Contents of the java.lang package.

Class IndexException Index Error IndexInterface Index
Boolean ArithmeticException AbstractMethodError Cloneable
Character ArrayIndexOutOfBoundsException ClassCircularityError Runnable
Class ArrayStoreException ClassFormatError  
ClassLoader ClassCastException Error 
Compiler ClassNotFoundException IllegalAccessError  
Double CloneNotSupportedException IncompatibleClassChangeError  
Float ExceptionInstantiationError  
Integer IllegalAccessException InternalError  
Long IllegalArgumentException LinkageError  
Math IllegalMonitorStateException NoClassDefFoundError  
Number IllegalThreadStateException NoSuchFieldError  
Object IndexOutOfBoundsException NoSuchMethodError  
Process InstantiationException OutOfMemoryError  
Runtime InterruptedException StackOverflowError  
SecurityManager NegativeArraySizeException ThreadDeath  
String NoSuchMethodException UnknownError  
StringBuffer NullPointerException UnsatisfiedLinkError  
System NumberFormatException VerifyError  
Thread RuntimeException VirtualMachineError  
ThreadGroup SecurityException   
Throwable StringIndexOutOfBoundsException    

Cloneable

Object

This interface indicates that an object can be cloned using the clone method defined in Object. The clone method clones an object by copying each of its member variables. At tempts to clone an object that doesn't implement the Cloneable interface results in a CloneNotSupportedException being thrown. The definition for the Cloneable interface follows:

public interface java.lang.Cloneable {
}

Runnable

Object

See also: Thread

This interface provides a means for an object to be executed within a thread without having to be derived from the Thread class. Classes implementing the Runnable interface supply a run method that defines the threaded execution for the class. The definition for the Runnable interface follows:

public interface java.lang.Runnable {
  // Methods
  public abstract void run();
}

run

Runnable

public abstract void run()

This method is executed when a thread associated with an object implementing the Runnable interface is started. All of the threaded execution for the object takes place in the run method, which means that you should place all threaded code in this method.

Boolean

Object

This class implements an object type wrapper for Boolean values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Boolean class provides support constants and methods for working with Boolean values. The definition for the Boolean class follows:

public final class java.lang.Boolean extends java.lang.Object {
  // Member Constants
  public final static Boolean FALSE;
  public final static Boolean TRUE;

  // Constructors
  public Boolean(boolean value);
  public Boolean(String s);

  // Methods
  public boolean booleanValue();
  public boolean equals(Object obj);
  public static boolean getBoolean(String name);
  public int hashCode();
  public String toString();
  public static Boolean valueOf(String s);
}

Member Constants

public final static Boolean FALSE

This is a constant Boolean object representing the primitive Boolean value FALSE.

public final static Boolean TRUE

This is a constant Boolean object representing the primitive Boolean value TRUE.

Boolean

Boolean

public Boolean(boolean value)

This constructor creates a Boolean wrapper object representing the specified primitive Boolean value.

value is the Boolean value to be wrapped.

Boolean

Boolean

public Boolean(String s)

This constructor creates a Boolean wrapper object representing the specified string. If the string is set to "true", the wrapper represents the primitive Boolean value TRUE; otherwise, the wrapper represents FALSE.

s is the string representation of a Boolean value to be wrapped.

booleanValue

Boolean

public boolean booleanValue()

This method determines the primitive Boolean value represented by this object.

The Boolean value represented.

equals

Boolean

public boolean equals(Object obj)

This method compares the Boolean value of the specified object to the Boolean value of this object. The equals method only returns TRUE if the specified object is a Boolean object representing the same primitive Boolean value as this object.

obj is the object to compare.

TRUE if the specified object is a Boolean object representing the same primitive Boolean value as this object; FALSE otherwise.

equals in class Object.

getBoolean

Boolean

public static boolean getBoolean(String name)

This method determines the Boolean value of the system property with the specified name.

Name is the system property name for which to check the Boolean value.

The Boolean value of the specified system property.

HashCode

Boolean

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

HashCode in class Object.

toString

Boolean

public String toString()

This method determines a string representation of the primitive Boolean value for this object. If the Boolean value is TRUE, the string "true" is returned; otherwise, the string "false" is returned.

A string representing the Boolean value of this object.

toString in class Object.

valueOf

Boolean

public static Boolean valueOf(String s)

This method creates a new Boolean wrapper object based on the Boolean value represented by the specified string. If the string is set to "true", the wrapper represents the primitive Boolean value TRUE; otherwise, the wrapper represents FALSE.

s is the string representation of a Boolean value to be wrapped.

A Boolean wrapper object representing the specified string.

Character

Object

This class implements an object type wrapper for character values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Character class provides support constants and methods for working with character values. The definition for the Character class follows:

public final class java.lang.Character extends java.lang.Object {
  // Member Constants
  public final static int MAX_RADIX;
  public final static char MAX_VALUE;
  public final static int MIN_RADIX;
  public final static char MIN_VALUE;

  // Constructors
  public Character(char value);

  // Methods
  public char charValue();
  public static int digit(char ch, int radix);
  public boolean equals(Object obj);
  public static char forDigit(int digit, int radix);
  public int hashCode();
  public static boolean isDefined(char ch);
  public static boolean isDigit(char ch);
  public static boolean isJavaLetter(char ch);
  public static boolean isJavaLetterOrDigit(char ch);
  public static boolean isLetter(char ch);
  public static boolean isLetterOrDigit(char ch);
  public static boolean isLowerCase(char ch);
  public static boolean isSpace(char ch);
  public static boolean isTitleCase(char ch);
  public static boolean isUpperCase(char ch);
  public static char toLowerCase(char ch);
  public String toString();
  public static char toTitleCase(char ch);
  public static char toUpperCase(char ch);
}

Member Constants

public final static int MAX_RADIX

This is a constant representing the maximum radix value allowed for conversion between numbers and strings. This constant is set to 36.

public final static int MAX_VALUE

This is a constant representing the largest character value supported. This constant is set to \uffff.

public final static int MIN_RADIX

This is a constant representing the minimum radix value allowed for conversion between numbers and strings. This constant is set to 2.

public final static int MIN_VALUE

This is a constant representing the smallest character value supported. This constant is set to \u0000.

Character

Character

public Character(char value)

This constructor creates a character wrapper object representing the specified primitive character value.

value is the character value to be wrapped.

charValue

Character

public char charValue()

This method determines the primitive character value represented by this object.

The character value represented.

digit

Character

public static int digit(char ch, int radix)

This method determines the numeric value of the specified character digit using the specified radix.

ch is the character to be converted to a number.

radix is the radix to use in the conversion.

The numeric value of the specified character digit using the specified radix, or -1 if the character isn't a valid numeric digit.

equals

Character

public boolean equals(Object obj)

This method compares the character value of the specified object to the character value of this object. The equals method only returns TRUE if the specified object is a Character object representing the same primitive character value as this object.

obj is the object to compare.

TRUE if the specified object is a Character object representing the same primitive character value as this object; otherwise, returns FALSE.

equals in class Object.

forDigit

Character

public static char forDigit(int digit, int radix)

This method determines the character value of the specified numeric digit using the specified radix.

digit is the numeric digit to be converted to a character.

radix is the radix to use in the conversion.

The character value of the specified numeric digit using the specified radix, or 0 if the number isn't a valid character.

hashCode

Character

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

isDefined

Character

public static boolean isDefined(char ch)

This method determines whether the specified character has a defined Unicode meaning. A character is defined if it has an entry in the Unicode attribute table.

ch is the character to be checked.

TRUE if the character has a defined Unicode meaning; otherwise, returns FALSE.

isDigit

Character

public static boolean isDigit(char ch)

This method determines whether the specified character is a numeric digit. A character is a numeric digit if its Unicode name contains the word DIGIT.

ch is the character to be checked.

TRUE if the character is a numeric digit; otherwise, returns FALSE.

isJavaLetter

Character

public static boolean isJavaLetter(char ch)

This method determines whether the specified character is permissible as the leading character in a Java identifier. A character is considered a Java letter if it is a letter, the ASCII dollar sign character ($), or the underscore character (_).

ch is the character to be checked.

TRUE if the character is a Java letter; otherwise, returns FALSE.

isJavaLetterOrDigit

Character

public static boolean isJavaLetterOrDigit(char ch)

This method determines whether the specified character is permissible as a nonleading character in a Java identifier. A character is considered a Java letter or digit if it is a letter, a digit, the ASCII dollar sign character ($), or the underscore character (_).

ch is the character to be checked.

TRUE if the character is a Java letter or digit; otherwise, returns FALSE.

isLetter

Character

public static boolean isLetter(char ch)

This method determines whether the specified character is a letter.

ch is the character to be checked.

TRUE if the character is a letter; otherwise, returns FALSE.

isLetterOrDigit

Character

public static boolean isLetterOrDigit(char ch)

This method determines whether the specified character is a letter or digit.

ch is the character to be checked.

TRUE if the character is a letter or digit; otherwise, returns FALSE.

isLowerCase

Character

public static boolean isLowerCase(char ch)

This method determines whether the specified character is a lowercase character.

ch is the character to be checked.

TRUE if the character is a lowercase character; otherwise, returns FALSE.

isSpace

Character

public static boolean isSpace(char ch)

This method determines whether the specified character is a whitespace character.

ch is the character to be checked.

TRUE if the character is a whitespace character; otherwise, returns FALSE.

isTitleCase

Character

public static boolean isTitleCase(char ch)

This method determines whether the specified character is a titlecase character. Titlecase characters are those for which the printed representations look like pairs of Latin letters.

ch is the character to be checked.

TRUE if the character is a titlecase character; otherwise, returns FALSE.

isUpperCase

Character

public static boolean isUpperCase(char ch)

This method determines whether the specified character is an uppercase character.

ch is the character to be checked.

TRUE if the character is an uppercase character; otherwise, returns FALSE.

toLowerCase

Character

public static char toLowerCase(char ch)

This method converts the specified character to a lowercase character if the character isn't already lowercase and a lowercase equivalent exists.

ch is the character to be converted.

The lowercase equivalent of the specified character, if one exists; otherwise, returns the original character.

toString

Character

public String toString()

This method determines a string representation of the primitive character value for this object; the resulting string is one character in length.

A string representing the character value of this object.

toString in class Object.

toTitleCase

Character

public static char toTitleCase(char ch)

This method converts the specified character to a titlecase character if the character isn't already a titlecase character and a titlecase equivalent exists. Titlecase characters are characters for which the printed representations look like pairs of Latin letters.

ch is the character to be converted.

The titlecase equivalent of the specified character, if one exists; otherwise, returns the original character.

toUpperCase

Character

public static char toUpperCase(char ch)

This method converts the specified character to an uppercase character if the character isn't already uppercase and an uppercase equivalent exists.

ch is the character to be converted.

The uppercase equivalent of the specified character, if one exists; otherwise, returns the original character.

Class

Object

This class implements a runtime descriptor for classes and interfaces in a running Java program. Instances of Class are constructed automatically by the Java virtual machine when classes are loaded, which explains why there are no public constructors for the class. The definition for the Class class follows:

public final class java.lang.Class extends java.lang.Object {
  // Methods
  public static Class forName(String className);
  public ClassLoader getClassLoader();
  public Class[] getInterfaces();
  public String getName();
  public Class getSuperclass();
  public boolean isInterface();
  public Object newInstance();
  public String toString();
}

forName

Class

public static Class forName(String className) throws ClassNotFoundException

This method determines the runtime class descriptor for the class with the specified name.

className is the fully qualified name of the desired class.

The runtime class descriptor for the class with the specified name.

ClassNotFoundException if the class could not be found.

getClassLoader

Class

public ClassLoader getClassLoader()

This method determines the class loader for this object.

The class loader for this object, or NULL if the class wasn't created by a class loader.

getInterfaces

Class

public Class[] getInterfaces()

This method determines the interfaces implemented by the class or interface represented by this object.

An array of interfaces implemented by the class or interface represented by this object, or an array of length 0 if no interfaces are implemented.

getName

Class

public String getName()

This method determines the fully qualified name of the class or interface represented by this object.

The fully qualified name of the class or interface represented by this object.

getSuperclass

Class

public Class getSuperclass()

This method determines the superclass of the class represented by this object.

The superclass of the class represented by this object, or NULL if this object represents the Object class.

isInterface

Class

public boolean isInterface()

This method determines whether the class represented by this object is actually an interface.

TRUE if the class is an interface; otherwise, returns FALSE.

newInstance

Class

public Object newInstance() throws InstantiationException, ÂIllegalAccessException

This method creates a new default instance of the class represented by this object.

A new default instance of the class represented by this object.

InstantiationException if you try to instantiate an abstract class or an interface, or if the instantiation fails for some other reason.

IllegalAccessException if the class is not accessible.

toString

Class

public String toString()

This method determines the name of the class or interface represented by this object, with the string "class" or the string "interface" prepended appropriately.

The name of the class or interface represented by this object, with a descriptive string prepended indicating whether the object represents a class or interface.

toString in class Object.

ClassLoader

Object

This class is an abstract class that defines a mechanism for dynamically loading classes into the Java runtime system. By default, the runtime system loads classes from files in the directory defined in the CLASSPATH environment variable. This is a platform-dependent process and doesn't involve ClassLoader objects. The ClassLoader class comes into play when you want to define other techniques of loading classes, such as across a network connection. The definition for the ClassLoader class follows:

public abstract class java.lang.ClassLoader extends java.lang.Object {
  // Constructors
  protected ClassLoader();

  // Methods
  protected final Class defineClass(byte data[], int off, int len);
  protected final Class findSystemClass(String name);
  protected abstract Class loadClass(String name, boolean resolve);
  protected final void resolveClass(Class c);
}

ClassLoader

ClassLoader

protected ClassLoader()

This constructor creates a default class loader. If a security manager is present, it is checked to see whether the current thread has permission to create the class loader. If not, a SecurityException is thrown.

SecurityException if the current thread doesn't have permission to create the class loader.

defineClass

ClassLoader

protected final Class defineClass(byte b[], int off, int len)

This method converts an array of bytes into an instance of class Class by reading len bytes from the array b beginning off bytes into the array.

b is the byte array containing the class data.

off is the starting offset into the array for the data.

len is the length in bytes of the class data.

A Class object created from the class data.

ClassFormatError if the class data does not define a valid class.

findSystemClass

ClassLoader

protected final Class findSystemClass(String name) throws ClassNotFoundException

This method finds the system class with the specified name, loading it if necessary. A system class is a class loaded from the local file system with no class loader in a platform-specific manner.

name is the name of the system class to find.

A Class object representing the system class.

ClassNotFoundException if the class is not found.

NoClassDefFoundError if a definition for the class is not found.

loadClass

ClassLoader

protected abstract Class loadClass(String name, boolean resolve) throws ÂClassNotFoundException

This method loads the class with the specified name, resolving it if the resolve parameter is set to TRUE. This method must be implemented in all derived class loaders, because it is defined as abstract.

name is the name of the desired class.

resolve is a Boolean value specifying whether the class is to be resolved. A value of TRUE means the class is resolved, whereas a value of FALSE means that the class isn't resolved.

The loaded Class object, or NULL if the class isn't found.

ClassNotFoundException if the class is not found.

resolveClass

ClassLoader

protected final void resolveClass(Class c)

This method resolves the specified class so that instances of it can be created or so that its methods can be called.

c is the class to be resolved.

Compiler

Object

This class provides the framework for native Java code compilers and related services. The Java runtime system looks for a native code compiler on startup, in which case the compiler is called to compile Java bytecode classes into native code. The default implementation for the Compiler class does nothing. The definition for the Compiler class follows:

public final class java.lang.Compiler extends java.lang.Object {
  // Methods
  public static Object command(Object any);
  public static boolean compileClass(Class clazz);
  public static boolean compileClasses(String string);
  public static void disable();
  public static void enable();
}

command

Compiler

public static Object command(Object any)

This method performs some compiler-specific operation based on the type of specified object and its related state.

any is the object on which to perform an operation.

A compiler-specific value, or NULL if no compiler is available.

compileClass

Compiler

public static boolean compileClass(Class clazz)

This method compiles the specified class.

clazz is the class to compile.

TRUE if the compilation was successful; FALSE if the compilation failed or if no compiler is available.

compileClasses

Compiler

public static boolean compileClasses(String string)

This method compiles all classes for which the names match the specified string name.

string is a string containing the name of the classes to compile.

TRUE if the compilation was successful; FALSE if the compilation failed or if no compiler is available.

Disable

Compiler

public static void disable()

This method disables the compiler.

Enable

Compiler

public static void enable()

This method enables the compiler.

Double

Number

This class implements an object type wrapper for double values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Double class provides support constants and methods for working with double values. The definition for the Double class follows:

public final class java.lang.Double extends java.lang.Number {
  // Member Constants
  public final static double MAX_VALUE;
  public final static double MIN_VALUE;
  public final static double NaN;
  public final static double NEGATIVE_INFINITY;
  public final static double POSITIVE_INFINITY;

  // Constructors
  public Double(double value);
  public Double(String s);

  // Methods
  public static long doubleToLongBits(double value);
  public double doubleValue();
  public boolean equals(Object obj);
  public float floatValue();
  public int hashCode();
  public int intValue();
  public boolean isInfinite();
  public static boolean isInfinite(double v);
  public boolean isNaN();
  public static boolean isNaN(double v);
  public static double longBitsToDouble(long bits);
  public long longValue();
  public String toString();
  public static String toString(double d);
  public static Double valueOf(String s);
}

Member Constants

public final static double MAX_VALUE

This is a constant representing the maximum value allowed for a double. This constant is set to 1.79769313486231570e+308d.

public final static double MIN_VALUE

This is a constant representing the minimum value allowed for a double. This constant is set to 4.94065645841246544e-324d.

public final static double NaN

This is a constant representing the not-a-number value for double types, which is not equal to anything, including itself.

public final static double NEGATIVE_INFINITY

This is a constant representing negative infinity for double types.

public final static double POSITIVE_INFINITY

This is a constant representing positive infinity for double types.

Double

Double

public Double(double value)

This constructor creates a double wrapper object representing the specified primitive double value.

value is the double value to be wrapped.

Double

Double

public Double(String s) throws NumberFormatException

This constructor creates a double wrapper object representing the specified string. The string is converted to a double using a similar technique as the valueOf method.

s is the string representation of a double value to be wrapped.

NumberFormatException if the string does not contain a parsable double.

DoubleToLongBits

Double

public static long doubleToLongBits(double value)

This method determines the IEEE 754 floating-point double precision representation of the specified double value. The IEEE 754 floating-point double precision format specifies the following bit layout:

value is the double value to convert to the IEEE 754 format.

The IEEE 754 floating-point representation of the specified double value.

doubleValue

Double

public double doubleValue()

This method determines the primitive double value represented by this object.

The double value represented.

doubleValue in class Number.

equals

Double

public boolean equals(Object obj)

This method compares the double value of the specified object to the double value of this object. The equals method returns TRUE only if the specified object is a Double object representing the same primitive double value as this object. Note that in order to be useful in hash tables, this method considers two NaN double values to be equal, even though NaN technically is not equal to itself.

obj is the object to compare.

TRUE if the specified object is a Double object representing the same primitive double value as this object; otherwise, returns FALSE.

equals in class Object.

floatValue

Double

public float floatValue()

This method converts the primitive double value represented by this object to a float.

A float conversion of the double value represented.

floatValue in class Number.

hashCode

Double

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

intValue

Double

public int intValue()

This method converts the primitive double value represented by this object to an integer.

An integer conversion of the double value represented.

intValue in class Number.

isInfinite

Double

public boolean isInfinite()

This method determines whether the primitive double value represented by this object is positive or negative infinity.

TRUE if the double value is positive or negative infinity; otherwise, returns FALSE.

isInfinite

Double

public static boolean isInfinite(double v)

This method determines whether the specified double value is positive or negative infinity.

v is the double value to be checked.

TRUE if the double value is positive or negative infinity; otherwise, returns FALSE.

isNaN

Double

public boolean isNaN()

This method determines whether the primitive double value represented by this object is not a number (NaN).

TRUE if the double value is not a number; otherwise, returns FALSE.

isNaN

Double

public static boolean isNaN(double v)

This method determines whether the specified double value is not a number (NaN).

v is the double value to be checked.

TRUE if the double value is not a number; otherwise, returns FALSE.

LongBitsToDouble

Double

public static double longBitsToDouble(long bits)

This method determines the double representation of the specified IEEE 754 floating-point double precision value. The IEEE 754 floating-point double precision format specifies the following bit layout:

bits is the IEEE 754 floating-point value to convert to a double.

The double representation of the specified IEEE 754 floating-point value.

longValue

Double

public long longValue()

This method converts the primitive double value represented by this object to a long.

A long conversion of the double value represented.

longValue in class Number.

toString

Double

public String toString()

This method determines a string representation of the primitive double value for this object.

A string representing the double value of this object.

toString in class Object.

toString

Double

public static String toString(double d)

This method determines a string representation of the specified double value.

d is the double value to be converted.

A string representing the specified double value.

valueOf

Double

public static Double valueOf(String s) throws NumberFormatException

This method creates a new double wrapper object based on the double value represented by the specified string.

s is the string representation of a double value to be wrapped.

A double wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable double.

Float

Number

This class implements an object type wrapper for float values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Float class provides support constants and methods for working with float values. The definition for the Float class follows:

public final class java.lang.Float extends java.lang.Number {
  // Member Constants
  public final static float MAX_VALUE;
  public final static float MIN_VALUE;
  public final static float NaN;
  public final static float NEGATIVE_INFINITY;
  public final static float POSITIVE_INFINITY;

  // Constructors
  public Float(double value);
  public Float(float value);
  public Float(String s);

  // Methods
  public double doubleValue();
  public boolean equals(Object obj);
  public static int floatToIntBits(float value);
  public float floatValue();
  public int hashCode();
  public static float intBitsToFloat(int bits);
  public int intValue();
  public boolean isInfinite();
  public static boolean isInfinite(float v);
  public boolean isNaN();
  public static boolean isNaN(float v);
  public long longValue();
  public String toString();
  public static String toString(float f);
  public static Float valueOf(String s);
}

Member Constants

public final static float MAX_VALUE

This is a constant representing the maximum value allowed for a float. This constant is set to 3.40282346638528860e+38.

public final static float MIN_VALUE

This is a constant representing the minimum value allowed for a float. This constant is set to 1.40129846432481707e-45.

public final static float NaN

This is a constant representing the not-a-number value for float types, which is not equal to anything, including itself.

public final static float NEGATIVE_INFINITY

This is a constant representing negative infinity for float types.

public final static float POSITIVE_INFINITY

This is a constant representing positive infinity for float types.

Float

Float

public Float(double value)

This constructor creates a float wrapper object representing the specified primitive double value.

value is the double value to be wrapped.

Float

Float

public Float(float value)

This constructor creates a float wrapper object representing the specified primitive float value.

value is the float value to be wrapped.

Float

Float

public Float(String s) throws NumberFormatException

This constructor creates a float wrapper object representing the specified string. The string is converted to a float using a technique similar to the valueOf method.

s is the string representation of a float value to be wrapped.

NumberFormatException if the string does not contain a parsable float.

doubleValue

Float

public double doubleValue()

This method converts the primitive float value represented by this object to a double.

A double conversion of the float value represented.

doubleValue in class Number.

equals

Float

public boolean equals(Object obj)

This method compares the float value of the specified object to the float value of this object. The equals method returns TRUE only if the specified object is a Float object representing the same primitive float value as this object. Note that in order to be useful in hash tables, this method considers two NaN float values to be equal, even though NaN technically is not equal to itself.

obj is the object to compare.

TRUE if the specified object is a Float object representing the same primitive float value as this object; otherwise, returns FALSE.

equals in class Object.

FloatToIntBits

Float

public static int floatToIntBits(float value)

This method determines the IEEE 754 floating-point single precision representation of the specified float value. The IEEE 754 floating-point single precision format specifies the following bit layout:

value is the float value to convert to the IEEE 754 format.

The IEEE 754 floating-point representation of the specified float value.

floatValue

Float

public float floatValue()

This method determines the primitive float value represented by this object.

The float value represented.

floatValue in class Number.

hashCode

Float

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

IntBitsToFloat

Float

public static float intBitsToFloat(int bits)

This method determines the float representation of the specified IEEE 754 floating-point single precision value. The IEEE 754 floating-point single precision format specifies the following bit layout:

bits is the IEEE 754 floating-point value to convert to a float.

The float representation of the specified IEEE 754 floating-point value.

intValue

Float

public int intValue()

This method converts the primitive float value represented by this object to an integer.

An integer conversion of the float value represented.

intValue in class Number.

isInfinite

Float

public boolean isInfinite()

This method determines whether the primitive float value represented by this object is positive or negative infinity.

TRUE if the float value is positive or negative infinity; otherwise, returns FALSE.

isInfinite

Float

public static boolean isInfinite(float v)

This method determines whether the specified float value is positive or negative infinity.

v is the float value to be checked.

TRUE if the float value is positive or negative infinity; otherwise, returns FALSE.

isNaN

Float

public boolean isNaN()

This method determines whether the primitive float value represented by this object is not a number (NaN).

TRUE if the float value is not a number; otherwise, returns FALSE.

isNaN

Float

public static boolean isNaN(float v)

This method determines whether the specified float value is not a number (NaN).

v is the float value to be checked.

TRUE if the float value is not a number; otherwise, returns FALSE.

longValue

Float

public long longValue()

This method converts the primitive float value represented by this object to a long.

A long conversion of the float value represented.

longValue in class Number.

toString

Float

public String toString()

This method determines a string representation of the primitive float value for this object.

A string representing the float value of this object.

toString in class Object.

toString

Float

public static String toString(float f)

This method determines a string representation of the specified float value.

f is the float value to be converted.

A string representing the specified float value.

valueOf

Float

public static Float valueOf(String s) throws NumberFormatException

This method creates a new float wrapper object based on the float value represented by the specified string.

s is the string representation of a float value to be wrapped.

A float wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable float.

Integer

Number

This class implements an object type wrapper for integer values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Integer class provides support constants and methods for working with integer values. The definition for the Integer class follows:

public final class java.lang.Integer extends java.lang.Number {
  // Member Constants
  public final static int MAX_VALUE;
  public final static int MIN_VALUE;

  // Constructors
  public Integer(int value);
  public Integer(String s);

  // Methods
  public double doubleValue();
  public boolean equals(Object obj);
  public float floatValue();
  public static Integer getInteger(String nm);
  public static Integer getInteger(String nm, int val);
  public static Integer getInteger(String nm, Integer val);
  public int hashCode();
  public int intValue();
  public long longValue();
  public static int parseInt(String s);
  public static int parseInt(String s, int radix);
  public static String toBinaryString(int i);
  public static String toHexString(int i);
  public static String toOctalString(int i);
  public String toString();
  public static String toString(int i);
  public static String  toString(int i, int radix);
  public static Integer valueOf(String s);
  public static Integer valueOf(String s, int radix);
}

Member Constants

public final static int MAX_VALUE

This is a constant representing the maximum value allowed for an integer. This constant is set to 0x7fffffff.

public final static int MIN_VALUE

This is a constant representing the minimum value allowed for an integer. This constant is set to 0x80000000.

Integer

Integer

public Integer(int value)

This constructor creates an integer wrapper object representing the specified primitive integer value.

value is the integer value to be wrapped.

Integer

Integer

public Integer(String s) throws NumberFormatException

This constructor creates an integer wrapper object representing the specified string. The string is converted to an integer using a technique similar to the valueOf method.

s is the string representation of an integer value to be wrapped.

NumberFormatException if the string does not contain a parsable integer.

doubleValue

Integer

public double doubleValue()

This method converts the primitive integer value represented by this object to a double.

A double conversion of the integer value represented.

doubleValue in class Number.

equals

Integer

public boolean equals(Object obj)

This method compares the integer value of the specified object to the integer value of this object. The equals method returns TRUE only if the specified object is an integer object representing the same primitive integer value as this object.

obj is the object to compare.

TRUE if the specified object is an integer object representing the same primitive integer value as this object; otherwise, returns FALSE.

equals in class Object.

floatValue

Integer

public float floatValue()

This method converts the primitive integer value represented by this object to a float.

A float conversion of the integer value represented.

floatValue in class Number.

getInteger

Integer

public static Integer getInteger(String nm)

This method determines an integer object representing the value of the system property with the specified name. If the system property doesn't exist, NULL is returned.

nm is the system property name for which to check the integer value.

An integer object representing the value of the specified system property, or NULL if the property doesn't exist.

getInteger

Integer

public static Integer getInteger(String nm, int val)

This method determines an integer object representing the value of the system property with the specified name. If the system property doesn't exist, an integer object representing the specified default property value is returned.

nm is the system property name for which to check the integer value.

val is the default integer property value.

An integer object representing the value of the specified system property, or an integer object representing val if the property doesn't exist.

getInteger

Integer

public static Integer getInteger(String nm, Integer val)

This method determines an integer object representing the value of the system property with the specified name. In addition, this version of getInteger includes support for reading hexadecimal and octal property values. If the system property doesn't exist, the specified default property value is returned.

nm is the system property name for which to check the integer value.

val is the default integer property value object.

An integer object representing the value of the specified system property, or val if the property doesn't exist.

hashCode

Integer

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

intValue

Integer

public int intValue()

This method determines the primitive integer value represented by this object.

The integer value represented.

intValue in class Number.

longValue

Integer

public long longValue()

This method converts the primitive integer value represented by this object to a long.

A long conversion of the integer value represented.

longValue in class Number.

parseInt

Integer

public static int parseInt(String s) throws NumberFormatException

This method parses a signed decimal integer value from the specified string. Note that all the characters in the string must be decimal digits, with the exception that the first character can be a minus character (-) to denote a negative number.

s is the string representation of an integer value.

The integer value represented by the specified string.

NumberFormatException if the string does not contain a parsable integer.

parseInt

Integer

public static int parseInt(String s, int radix) throws NumberFormatException

This method parses a signed integer value in the specified radix from the specified string. Note that all the characters in the string must be digits in the specified radix, with the exception that the first character can be a minus character (-) to denote a negative number.

s is the string representation of an integer value.

radix is the radix to use for the integer.

The integer value represented by the specified string.

NumberFormatException if the string does not contain a parsable integer.

toBinaryString

Integer

public static String toBinaryString(int i)

This method determines a string representation of the specified unsigned base 2 integer value.

i is the unsigned base 2 integer value to be converted.

A string representing the specified unsigned base 2 integer value.

toHexString

Integer

public static String toHexString(int i)

This method determines a string representation of the specified unsigned base 16 integer value.

i is the unsigned base 16 integer value to be converted.

A string representing the specified unsigned base 16 integer value.

toOctalString

Integer

public static String toOctalString(int i)

This method determines a string representation of the specified unsigned base 8 integer value.

i is the unsigned base 8 integer value to be converted.

A string representing the specified unsigned base 8 integer value.

toString

Integer

public String toString()

This method determines a string representation of the primitive decimal integer value for this object.

A string representing the decimal integer value of this object.

toString in class Object.

toString

Integer

public static String toString(int i)

This method determines a string representation of the specified decimal integer value.

i is the decimal integer value to be converted.

A string representing the specified decimal integer value.

toString

Integer

public static String toString(int i, int radix)

This method determines a string representation of the specified integer value in the specified radix.

i is the integer value to be converted.

radix is the radix to use for the conversion.

A string representing the specified integer value in the specified radix.

valueOf

Integer

public static Integer valueOf(String s) throws NumberFormatException

This method creates a new integer wrapper object based on the decimal integer value represented by the specified string.

s is the string representation of a decimal integer value to be wrapped.

An integer wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable integer.

valueOf

Integer

public static Integer valueOf(String s, int radix) throws NumberFormatException

This method creates a new integer wrapper object based on the integer value in the specified radix represented by the specified string.

s is the string representation of an integer value to be wrapped.

radix is the radix to use for the integer.

An integer wrapper object in the specified radix representing the specified string.

NumberFormatException if the string does not contain a parsable integer.

Long

Number

This class implements an object type wrapper for long values. Object type wrappers are useful because many Java classes operate on objects rather than primitive data types. In addition, the Long class provides support constants and methods for working with long values. The definition for the Long class follows:

public final class java.lang.Long extends java.lang.Number {
  // Member Constants
  public final static long MAX_VALUE;
  public final static long MIN_VALUE;

  // Constructors
  public Long(long value);
  public Long(String s);

  // Methods
  public double doubleValue();
  public boolean equals(Object obj);
  public float floatValue();
  public static Long getLong(String nm);
  public static Long getLong(String nm, long val);
  public static Long getLong(String nm, Long val);
  public int hashCode();
  public int intValue();
  public long longValue();
  public static long parseLong(String s);
  public static long parseLong(String s, int radix);
  public static String toBinaryString(long i);
  public static String toHexString(long i);
  public static String toOctalString(long i);
  public String toString();
  public static String toString(long i);
  public static String toString(long i, int radix);
  public static Long valueOf(String s);
  public static Long valueOf(String s, int radix);
}

Member Constants

public final static int MAX_VALUE

This is a constant representing the maximum value allowed for a long. This constant is set to 0x7fffffffffffffff.

public final static int MIN_VALUE

This is a constant representing the minimum value allowed for a long. This constant is set to 0x8000000000000000.

Long

Long

public Long(long value)

This constructor creates a long wrapper object representing the specified primitive long value.

value is the long value to be wrapped.

Long

Long

public Long(String s) throws NumberFormatException

This constructor creates a long wrapper object representing the specified string. The string is converted to a long using a technique similar to the valueOf method.

s is the string representation of a long value to be wrapped.

NumberFormatException if the string does not contain a parsable long.

doubleValue

Long

public double doubleValue()

This method converts the primitive long value represented by this object to a double.

A double conversion of the long value represented.

doubleValue in class Number.

equals

Long

public boolean equals(Object obj)

This method compares the long value of the specified object to the long value of this object. The equals method returns TRUE only if the specified object is a long object representing the same primitive long value as this object.

obj is the object to compare.

TRUE if the specified object is a Long object representing the same primitive long value as this object; otherwise, FALSE.

equals in class Object.

floatValue

Long

public float floatValue()

This method converts the primitive long value represented by this object to a float.

A float conversion of the long value represented.

floatValue in class Number.

getLong

Long

public static Long getLong(String nm)

This method determines a long object representing the value of the system property with the specified name. If the system property doesn't exist, NULL is returned.

nm is the system property name for which to check the long value.

A long object representing the value of the specified system property, or NULL if the property doesn't exist.

getLong

Long

public static Long getLong(String nm, long val)

This method determines a long object representing the value of the system property with the specified name. If the system property doesn't exist, a long object representing the specified default property value is returned.

nm is the system property name for which to check the long value.

val is the default long property value.

A long object representing the value of the specified system property, or a long object representing val if the property doesn't exist.

getLong

Long

public static Long getLong(String nm, Long val)

This method determines a long object representing the value of the system property with the specified name. In addition, this version of getLong includes support for reading hexadecimal and octal property values. If the system property doesn't exist, the specified default property value is returned.

nm is the system property name for which to check the long value.

val is the default long property value object.

A long object representing the value of the specified system property, or val if the property doesn't exist.

hashCode

Long

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

intValue

Long

public int intValue()

This method converts the primitive long value represented by this object to an integer.

An integer conversion of the long value represented.

intValue in class Number.

longValue

Long

public long longValue()

This method determines the primitive long value represented by this object.

The long value represented.

longValue in class Number.

parseLong

Long

public static long parseLong(String s) throws NumberFormatException

This method parses a signed decimal long value from the specified string. Note that all the characters in the string must be decimal digits, with the exception that the first character can be a minus character (-) to denote a negative number.

s is the string representation of a long value.

The long value represented by the specified string.

NumberFormatException if the string does not contain a parsable long.

parseLong

Long

public static long parseLong(String s, int radix) throws NumberFormatException

This method parses a signed long value in the specified radix from the specified string. Note that all the characters in the string must be digits in the specified radix, with the exception that the first character can be a minus character (-) to denote a negative number.

s is the string representation of a long value.

radix is the radix to use for the long.

The long value represented by the specified string.

NumberFormatException if the string does not contain a parsable long.

toBinaryString

Long

public static String toBinaryString(long l)

This method determines a string representation of the specified unsigned base 2 long value.

l is the unsigned base 2 long value to be converted.

A string representing the specified unsigned base 2 long value.

toHexString

Long

public static String toHexString(long l)

This method determines a string representation of the specified unsigned base 16 long value.

l is the unsigned base 16 long value to be converted.

A string representing the specified unsigned base 16 long value.

toOctalString

Long

public static String toOctalString(long l)

This method determines a string representation of the specified unsigned base 8 long value.

l is the unsigned base 8 long value to be converted.

A string representing the specified unsigned base 8 long value.

toString

Long

public String toString()

This method determines a string representation of the primitive decimal long value for this object.

A string representing the decimal long value of this object.

toString in class Object.

toString

Long

public static String toString(long l)

This method determines a string representation of the specified decimal long value.

l is the decimal long value to be converted.

A string representing the specified decimal long value.

toString

Long

public static String toString(long l, int radix)

This method determines a string representation of the specified long value in the specified radix.

i is the long value to be converted.

radix is the radix to use for the conversion.

A string representing the specified long value in the specified radix.

valueOf

Long

public static Long valueOf(String s) throws NumberFormatException

This method creates a new long wrapper object based on the decimal long value represented by the specified string.

s is the string representation of a decimal long value to be wrapped.

A long wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable long.

valueOf

Long

public static Long valueOf(String s, int radix) throws NumberFormatException

This method creates a new long wrapper object based on the long value in the specified radix represented by the specified string.

s is the string representation of a long value to be wrapped.

radix is the radix to use for the long.

A long wrapper object in the specified radix representing the specified string.

NumberFormatException if the string does not contain a parsable long.

Math

Object

This class implements a library of common math functions, including methods for performing basic numerical operations such as elementary exponential, logarithm, square root, and trigonometric functions. The definition for the Math class follows:

public final class java.lang.Math extends java.lang.Object {
  // Member Constants
  public final static double E;
  public final static double PI;

  // Methods
  public static double abs(double a);
  public static float abs(float a);
  public static int abs(int a);
  public static long abs(long a);
  public static double acos(double a);
  public static double asin(double a);
  public static double atan(double a);
  public static double atan2(double a, double b);
  public static double ceil(double a);
  public static double cos(double a);
  public static double exp(double a);
  public static double floor(double a);
  public static double IEEEremainder(double f1, double f2);
  public static double log(double a);
  public static double max(double a, double b);
  public static float max(float a, float b);
  public static int max(int a, int b);
  public static long max(long a, long b);
  public static double min(double a, double b);
  public static float min(float a, float b);
  public static int min(int a, int b);
  public static long min(long a, long b);
  public static double pow(double a, double b);
  public static double random();
  public static double rint(double a);
  public static long round(double a);
  public static int round(float a);
  public static double sin(double a);
  public static double sqrt(double a);
  public static double tan(double a);
}

Member Constants

public final static double E

This is a constant representing the double value of E, which is the base of the natural logarithms. This constant is set to 2.7182818284590452354.

public final static double PI

This is a constant representing the double value of PI, which is the ratio of the circumference of a circle to its diameter. This constant is set to 3.14159265358979323846.

abs

Math

public static double abs(double a)

This method calculates the absolute value of the specified double value.

a is the double value for which to calculate the absolute value.

The absolute value of the double value.

abs

Math

public static float abs(float a)

This method calculates the absolute value of the specified float value.

a is the float value for which to calculate the absolute value.

The absolute value of the float value.

abs

Math

public static int abs(int a)

This method calculates the absolute value of the specified integer value.

a is the integer value for which to calculate the absolute value.

The absolute value of the integer value.

abs

Math

public static long abs(long a)

This method calculates the absolute value of the specified long value.

a is the long value for which to calculate the absolute value.

The absolute value of the long value.

acos

Math

public static double acos(double a)

This method calculates the arccosine of the specified double value.

a is the double value for which to calculate the arccosine.

The arccosine of the double value.

asin

Math

public static double asin(double a)

This method calculates the arcsine of the specified double value.

a is the double value for which to calculate the arcsine.

The arcsine of the double value.

atan

Math

public static double atan(double a)

This method calculates the arctangent of the specified double value.

a is the double value for which to calculate the arctangent.

The arctangent of the double value.

atan2

Math

public static double atan2(double a, double b)

This method calculates the theta component of the polar coordinate (r, theta) corresponding to the rectangular coordinate (x, y) specified by the double values.

a is the x component value of the rectangular coordinate.

b is the y component value of the rectangular coordinate.

The theta component of the polar coordinate corresponding to the rectangular coordinate specified by the double values.

ceil

Math

public static double ceil(double a)

This method determines the smallest double whole number that is greater than or equal to the specified double value.

a is the double value for which to calculate the ceiling.

The smallest double whole number that is greater than or equal to the specified double value.

Cos

Math

public static double cos(double a)

This method calculates the cosine of the specified double value, which is specified in radians.

a is the double value for which to calculate the cosine, in radians.

The cosine of the double value.

Exp

Math

public static double exp(double a)

This method calculates the exponential value of the specified double value, which is E raised to the power of a.

a is the double value for which to calculate the exponential value.

The exponential value of the specified double value.

floor

Math

public static double floor(double a)

This method determines the largest double whole number that is less than or equal to the specified double value.

a is the double value for which to calculate the floor.

The largest double whole number that is less than or equal to the specified double value.

IEEEremainder

Math

public static double IEEEremainder(double f1, double f2)

This method calculates the remainder of f1 divided by f2, as defined by the IEEE 754 standard.

f1 is the dividend for the division operation.

f2 is the divisor for the division operation.

The remainder of f1 divided by f2, as defined by the IEEE 754 standard.

log

Math

public static double log(double a) throws ArithmeticException

This method calculates the natural logarithm (base E) of the specified double value.

a is the double value, which is greater than 0.0, for which to calculate the natural logarithm.

The natural logarithm of the specified double value.

ArithmeticException if the specified double value is less than 0.0.

max

Math

public static double max(double a, double b)

This method determines the larger of the two specified double values.

a is the first double value to be compared.

b is the second double value to be compared.

The larger of the two specified double values.

max

Math

public static float max(float a, float b)

This method determines the larger of the two specified float values.

a is the first float value to be compared.

b is the second float value to be compared.

The larger of the two specified float values.

max

Math

public static int max(int a, int b)

This method determines the larger of the two specified integer values.

a is the first integer value to be compared.

b is the second integer value to be compared.

The larger of the two specified integer values.

max

Math

public static long max(long a, long b)

This method determines the larger of the two specified long values.

a is the first long value to be compared.

b is the second long value to be compared.

The larger of the two specified long values.

min

Math

public static double min(double a, double b)

This method determines the smaller of the two specified double values.

a is the first double value to be compared.

b is the second double value to be compared.

The smaller of the two specified double values.

min

Math

public static float min(float a, float b)

This method determines the smaller of the two specified float values.

a is the first float value to be compared.

b is the second float value to be compared.

The smaller of the two specified float values.

min

Math

public static int min(int a, int b)

This method determines the smaller of the two specified integer values.

a is the first integer value to be compared.

b is the second integer value to be compared.

The smaller of the two specified integer values.

min

Math

public static long min(long a, long b)

This method determines the smaller of the two specified long values.

a is the first long value to be compared.

b is the second long value to be compared.

The smaller of the two specified long values.

pow

Math

public static double pow(double a, double b) throws ArithmeticException

This method calculates the double value a raised to the power of b. Note that if a equals 0.0, b must be greater than 0.0; otherwise, an ArithmeticException is thrown. Also, if a is less than or equal to 0.0 and b is not a whole number, an ArithmeticException is thrown.

a is a double value to be raised to a power specified by b.

b is the power by which to raise a.

The double value a raised to the power of b.

ArithmeticException if a equals 0.0 and b is less than or equal to 0.0, or if a is less than or equal to 0.0 and b is not a whole number.

random

Math

public static double random()

This method generates a pseudo-random double between 0.0 and 1.0.

A pseudo-random double between 0.0 and 1.0.

rint

Math

public static double rint(double a)

This method determines the closest whole number to the specified double value. If the double value is equally spaced between two whole numbers, rint returns the even number.

a is the double value used to determine the closest whole number.

The closest whole number to the specified double value.

round

Math

public static long round(double a)

This method rounds off the specified double value by determining the closest long value.

a is the double value to round off.

The closest long value to the specified double value.

round

Math

public static int round(float a)

This method rounds off the specified float value by determining the closest integer value.

a is the float value to round off.

The closest integer value to the specified float value.

sin

Math

public static double sin(double a)

This method calculates the sine of the specified double value, which is specified in radians.

a is the double value of which to calculate the sine, in radians.

The sine of the double value.

sqrt

Math

public static double sqrt(double a) throws ArithmeticException

This method calculates the square root of the specified double value.

a is the double value, which is greater than 0.0, for which to calculate the square root.

The square root of the double value.

ArithmeticException if the specified double value is less than 0.0.

tan

Math

public static double tan(double a)

This method calculates the tangent of the specified double value, which is specified in radians.

a is the double value of which to calculate the tangent, in radians.

The tangent of the double value.

Number

Object

See also: Double, Float, Integer, Long

This class is an abstract class that provides the basic functionality required of a numeric object. All specific numeric objects are derived from Number. The definition for the Number class follows:

public abstract class java.lang.Number extends java.lang.Object {
  // Methods
  public abstract double doubleValue();
  public abstract float floatValue();
  public abstract int intValue();
  public abstract long longValue();
}

doubleValue

Number

public abstract double doubleValue()

This method determines the primitive double value represented by this object. Note that this may involve rounding if the number is not already a double.

The double value represented.

floatValue

Number

public abstract float floatValue()

This method determines the primitive float value represented by this object. Note that this may involve rounding if the number is not already a float.

The float value represented.

intValue

Number

public abstract int intValue()

This method determines the primitive integer value represented by this object.

The integer value represented.

longValue

Number

public abstract long longValue()

This method determines the primitive long value represented by this object.

The long value represented.

Object

This class is the root of the Java class hierarchy, providing the core functionality required of all objects. All classes have Object as a superclass, and all classes implement the methods defined in Object. The definition for the Object class follows:

public class java.lang.Object {
  // Constructors
  public Object();

  // Methods
  protected Object clone();
  public boolean equals(Object obj);
  protected void finalize();
  public final Class getClass();
  public int hashCode();
  public final void notify();
  public final void notifyAll();
  public String toString();
  public final void wait();
  public final void wait(long timeout);
  public final void wait(long timeout, int nanos);
}

Object

Object

public Object()

This constructor creates a default object.

clone

Object

protected Object clone() throws CloneNotSupportedException

This method creates a clone of this object by creating a new instance of the class and copying each of the member variables of this object to the new object. To be cloneable, derived classes must implement the Cloneable interface.

A clone of this object.

OutOfMemoryError if there is not enough memory.

CloneNotSupportedException if the object doesn't support the Cloneable interface or if it explicitly doesn't want to be cloned.

equals

Object

public boolean equals(Object obj)

This method compares this object with the specified object for equality. The equals method is used by the Hashtable class to compare objects stored in the hash table.

obj is the object to compare.

TRUE if this object is equivalent to the specified object; otherwise, returns FALSE.

finalize

Object

protected void finalize() throws Throwable

This method is called by the Java garbage collector when an object is being destroyed. The default behavior of finalize is to do nothing. Derived classes can override finalize to include cleanup code that is to be executed when the object is destroyed. Note that any exception thrown by the finalize method causes the finalization to halt.

getClass

Object

public final Class getClass()

This method determines the runtime class descriptor for this object.

The runtime class descriptor for this object.

hashCode

Object

public int hashCode()

This method calculates a hash code for this object, which is a unique integer identifying the object. Hash codes are used by the Hashtable class.

A hash code for this object.

notify

Object

public final void notify()

This method wakes up a single thread that is waiting on this object's monitor. A thread is set to wait on an object's monitor when the wait method is called. The notify method should be called only by a thread that is the owner of this object's monitor. Note that the notify method can be called only from within a synchronized method.

IllegalMonitorStateException if the current thread is not the owner of this object's monitor.

notifyAll

Object

public final void notifyAll()

This method wakes up all threads that are waiting on this object's monitor. A thread is set to wait on an object's monitor when the wait method is called. The notifyAll method should be called only by a thread that is the owner of this object's monitor. Note that the notifyAll method can be called only from within a synchronized method.

IllegalMonitorStateException if the current thread is not the owner of this object's monitor.

toString

Object

public String toString()

This method determines a string representation of this object. It is recommended that all derived classes override toString.

A string representing this object.

wait

Object

public final void wait() throws InterruptedException

This method causes the current thread to wait forever until it is notified via a call to the notify or notifyAll method. The wait method should be called only by a thread that is the owner of this object's monitor. Note that the wait method can be called only from within a synchronized method.

IllegalMonitorStateException if the current thread is not the owner of this object's monitor.

InterruptedException if another thread has interrupted this thread.

wait

Object

public final void wait(long timeout) throws InterruptedException

This method causes the current thread to wait until it is notified via a call to the notify or notifyAll method, or until the specified timeout period has elapsed. The wait method should be called only by a thread that is the owner of this object's monitor. Note that the wait method can be called only from within a synchronized method.

timeout is the maximum timeout period to wait, in milliseconds.

IllegalMonitorStateException if the current thread is not the owner of this object's monitor.

InterruptedException if another thread has interrupted this thread.

wait

Object

public final void wait(long timeout, int nanos) throws InterruptedException

This method causes the current thread to wait until it is notified via a call to the notify or notifyAll method, or until the specified timeout period has elapsed. The timeout period, in this case, is the addition of the timeout and nanos parameters, which provide finer control over the timeout period. The wait method should be called only by a thread that is the owner of this object's monitor. Note that the wait method can be called only from within a synchronized method.

timeout is the maximum timeout period to wait, in milliseconds.

nanos is the additional time for the timeout period, in nanoseconds.

IllegalMonitorStateException if the current thread is not the owner of this object's monitor.

InterruptedException if another thread has interrupted this thread.

Process

Object

See also: Runtime

This class is an abstract class that provides the basic functionality required of a system process. Derived Process objects (subprocesses) are returned from the exec methods defined in the Runtime class. The definition for the Process class follows:

public abstract class java.lang.Process extends java.lang.Object {
  // Constructors
  public Process();

  // Methods
  public abstract void destroy();
  public abstract int exitValue();
  public abstract InputStream getErrorStream();
  public abstract InputStream getInputStream();
  public abstract OutputStream getOutputStream();
  public abstract int waitFor();
}

Process

Process

public Process()

This constructor creates a default process.

destroy

Process

public abstract void destroy()

This method kills the subprocess.

exitValue

Process

public abstract int exitValue()

This method determines the exit value of the subprocess.

The integer exit value for the subprocess.

IllegalThreadStateException if the subprocess has not yet terminated.

getErrorStream

Process

public abstract InputStream getErrorStream()

This method determines the error stream associated with the subprocess.

The error stream associated with the subprocess.

getInputStream

Process

public abstract InputStream getInputStream()

This method determines the input stream associated with the subprocess.

The input stream associated with the subprocess.

getOutputStream

Process

public abstract OutputStream getOutputStream()

This method determines the output stream associated with the subprocess.

The output stream associated with the subprocess.

waitFor

Process

public abstract int waitFor() throws InterruptedException

This method waits for the subprocess to finish executing. When the subprocess finishes executing, the integer exit value is returned.

The integer exit value for the subprocess.

InterruptedException if another thread has interrupted this thread.

Runtime

Object

See also: System, Process

This class provides a mechanism for interacting with the Java runtime environment. Each running Java application has access to a single instance of the Runtime class, which it can use to query and modify the runtime environment. Note that Runtime objects cannot be created directly by a Java program. The definition for the Runtime class follows:

public class java.lang.Runtime extends java.lang.Object {
  // Methods
  public Process exec(String command);
  public Process exec(String command, String envp[]);
  public Process exec(String cmdarray[]);
  public Process exec(String cmdarray[], String envp[]);
  public void exit(int status);
  public long freeMemory();
  public void gc();
  public InputStream getLocalizedInputStream(InputStream in);
  public OutputStream getLocalizedOutputStream(OutputStream out);
  public static Runtime getRuntime();
  public void load(String filename);
  public void loadLibrary(String libname);
  public void runFinalization();
  public long totalMemory();
  public void traceInstructions(boolean on);
  public void traceMethodCalls(boolean on);
}

exec

Runtime

public Process exec(String command) throws IOException

This method executes the system command represented by the specified string in a separate subprocess.

command is a string representing the system command to execute.

The subprocess that is executing the system command.

SecurityException if the current thread cannot create the subprocess.

exec

Runtime

public Process exec(String command, String envp[]) throws IOException

This method executes the system command represented by the specified string in a separate subprocess with the specified environment.

command is a string representing the system command to execute.

envp is an array of strings representing the environment.

The subprocess that is executing the system command.

SecurityException if the current thread cannot create the subprocess.

exec

Runtime

public Process exec(String cmdarray[]) throws IOException

This method executes the system command with arguments represented by the specified string array in a separate subprocess.

cmdarray is an array of strings representing the system command to execute along with its arguments.

The subprocess that is executing the system command.

SecurityException if the current thread cannot create the subprocess.

exec

Runtime

public Process exec(String cmdarray[], String envp[]) throws IOException

This method executes the system command with arguments represented by the specified string array in a separate subprocess with the specified environment.

cmdarray is an array of strings representing the system command to execute along with its arguments.

envp is an array of strings representing the environment.

The subprocess that is executing the system command.

SecurityException if the current thread cannot create the subprocess.

exit

Runtime

public void exit(int status)

This method exits the Java runtime system (virtual machine) with the specified integer exit status. Note that because exit kills the runtime system, it never returns.

status is the integer exit status; this should be set to nonzero if this is an abnormal exit.

SecurityException if the current thread cannot exit with the specified exit status.

freeMemory

Runtime

public long freeMemory()

This method determines the approximate amount of free memory available in the runtime system, in bytes. Note that calling the gc method may free up more memory.

Approximate amount of free memory available, in bytes.

gc

Runtime

public void gc()

This method invokes the Java garbage collector to clean up any objects that no longer are needed, usually resulting in more free memory.

getLocalizedInputStream

Runtime

public InputStream getLocalizedInputStream(InputStream in)

This method creates a localized input stream based on the specified input stream. A localized input stream is a stream in which the local characters are mapped to Unicode characters as they are read.

in is the input stream to localize.

A localized input stream based on the specified input stream.

getLocalizedOutputStream

Runtime

public OutputStream getLocalizedOutputStream(OutputStream out)

This method creates a localized output stream based on the specified output stream. A localized output stream is a stream in which Unicode characters are mapped to local characters as they are written.

out is the output stream to localize.

A localized output stream based on the specified output stream.

getRuntime

Runtime

public static Runtime getRuntime()

This method gets the runtime environment object associated with the current Java program.

The runtime environment object associated with the current Java program.

load

Runtime

public void load(String pathname)

This method loads the dynamic library with the specified complete path name.

pathname is the path name of the library to load.

UnsatisfiedLinkError if the library doesn't exist.

SecurityException if the current thread can't load the library.

loadLibrary

Runtime

public void loadLibrary(String libname)

This method loads the dynamic library with the specified library name. Note that the mapping from library name to a specific filename is performed in a platform-specific manner.

libname is the name of the library to load.

UnsatisfiedLinkError if the library doesn't exist.

SecurityException if the current thread can't load the library.

runFinalization

Runtime

public void runFinalization()

This method explicitly causes the finalize methods of any discarded objects to be called. Typically, the finalize methods of discarded objects are automatically called asynchronously when the garbage collector cleans up the objects. You can use runFinalization to have the finalize methods called synchronously.

totalMemory

Runtime

public long totalMemory()

This method determines the total amount of memory in the runtime system, in bytes.

The total amount of memory, in bytes.

traceInstructions

Runtime

public void traceInstructions(boolean on)

This method is used to determine whether the Java virtual machine prints out a detailed trace of each instruction executed.

on is a Boolean value specifying whether the Java virtual machine prints a detailed trace of each instruction executed. A value of TRUE means that the instruction trace is printed, whereas a value of FALSE means that the instruction trace isn't printed.

traceMethodCalls

Runtime

public void traceMethodCalls(boolean on)

This method is used to determine whether the Java virtual machine prints a detailed trace of each method that is called.

on is a Boolean value specifying whether the Java virtual machine prints a detailed trace of each method that is called. A value of TRUE means that the method call trace is printed, whereas a value of FALSE means that the method call trace isn't printed.

SecurityManager

Object

This class is an abstract class that defines a security policy that can be used by Java programs to check for potentially unsafe operations. The definition for the SecurityManager class follows:

public abstract class java.lang.SecurityManager extends java.lang.Object {
  // Member Variables
  protected boolean inCheck;

  // Constructors
  protected SecurityManager();

  // Methods
  public void  checkAccept(String host, int port);
  public void checkAccess(Thread g);
  public void checkAccess(ThreadGroup g);
  public void checkConnect(String host, int port);
  public void checkConnect(String host, int port, Object context);
  public void checkCreateClassLoader();
  public void checkDelete(String file);
  public void checkExec(String cmd);
  public void checkExit(int status);
  public void checkLink(String lib);
  public void checkListen(int port);
  public void checkPackageAccess(String pkg);
  public void checkPackageDefinition(String pkg);
  public void checkPropertiesAccess();
  public void checkPropertyAccess(String key);
  public void checkRead(FileDescriptor fd);
  public void checkRead(String file);
  public void checkRead(String file, Object context);
  public void checkSetFactory();
  public boolean checkTopLevelWindow(Object window);
  public void checkWrite(FileDescriptor fd);
  public void checkWrite(String file);
  protected int classDepth(String name);
  protected int classLoaderDepth();
  protected ClassLoader currentClassLoader();
  protected Class[] getClassContext();
  public boolean getInCheck();
  public Object getSecurityContext();
  protected boolean inClass(String name);
  protected boolean inClassLoader();
}

Member Variables

protected boolean inCheck

This member variable specifies whether a security check is in progress. A value of TRUE indicates that a security check is in progress, whereas a value of FALSE means that no check is taking place.

SecurityManager

SecurityManager

protected SecurityManager()

This constructor creates a default security manager. Note that only one security manager is allowed for each Java program.

SecurityException if the security manager cannot be created.

checkAccept

SecurityManager

public void checkAccept(String host, int port)

This method checks to see whether the calling thread is allowed to establish a socket connection to the specified port on the specified host.

host is the host name to which the socket will be connected.

port is the number of the port to which the socket will be connected.

SecurityException if the calling thread doesn't have permission to establish the socket connection.

checkAccess

SecurityManager

public void checkAccess(Thread g)

This method checks to see whether the calling thread is allowed access to the specified thread.

g is the thread to check for access.

SecurityException if the calling thread doesn't have access to the specified thread.

checkAccess

SecurityManager

public void checkAccess(ThreadGroup g)

This method checks to see whether the calling thread is allowed access to the specified thread group.

g is the thread group to check for access.

SecurityException if the calling thread doesn't have access to the specified thread group.

checkConnect

SecurityManager

public void checkConnect(String host, int port)

This method checks to see whether the calling thread has established a socket connection to the specified port on the specified host.

host is the host name for which to check the connection.

sort is the number of the port for which to check the connection.

SecurityException if the calling thread doesn't have permission to establish the socket connection.

checkConnect

SecurityManager

public void checkConnect(String host, int port, Object context)

This method checks to see whether the specified security context has established a socket connection to the specified port on the specified host.

host is the host name for which to check the connection.

port is the number of the port for which to check the connection.

context is the security context for the check.

SecurityException if the specified security context doesn't have permission to establish the socket connection.

checkCreateClassLoader

SecurityManager

public void checkCreateClassLoader()

This method checks to see whether the calling thread is allowed access to create a new class loader.

SecurityException if the calling thread doesn't have permission to create a new class loader.

checkDelete

SecurityManager

public void checkDelete(String file)

This method checks to see whether the calling thread is allowed access to delete the file with the specified platform-specific filename.

file is the platform-specific filename for the file to be checked.

SecurityException if the calling thread doesn't have permission to delete the file.

checkExec

SecurityManager

public void checkExec(String cmd)

This method checks to see whether the calling thread is allowed access to create a subprocess to execute the specified system command.

cmd is a string representing the system command to be checked.

SecurityException if the calling thread doesn't have permission to create a subprocess to execute the system command.

checkExit

SecurityManager

public void checkExit(int status)

This method checks to see whether the calling thread is allowed access to exit the Java runtime system with the specified exit status.

status is the integer exit status to be checked.

SecurityException if the calling thread doesn't have permission to exit with the specified exit status.

checkLink

SecurityManager

public void checkLink(String lib)

This method checks to see whether the calling thread is allowed access to dynamically link the library with the specified name.

lib is the name of the library to be checked.

SecurityException if the calling thread doesn't have permission to dynamically link the library.

checkListen

SecurityManager

public void checkListen(int port)

This method checks to see whether the calling thread is allowed to wait for a connection request on the specified port.

port is the number of the port for which to check the connection.

SecurityException if the calling thread doesn't have permission to wait for a connection request on the specified port.

checkPackageAccess

SecurityManager

public void checkPackageAccess(String pkg)

This method checks to see whether the calling thread is allowed access to the package with the specified name.

pkg is the name of the package to be checked.

SecurityException if the calling thread doesn't have permission to access the package.

checkPackageDefinition

SecurityManager

public void checkPackageDefinition(String pkg)

This method checks to see whether the calling thread is allowed to define classes in the package with the specified name.

pkg is the name of the package to be checked.

SecurityException if the calling thread doesn't have permission to define classes in the package.

checkPropertiesAccess

SecurityManager

public void checkPropertiesAccess()

This method checks to see whether the calling thread is allowed access to the system properties.

SecurityException if the calling thread doesn't have permission to access the system properties.

checkPropertyAccess

SecurityManager

public void checkPropertyAccess(String key)

This method checks to see whether the calling thread is allowed access to the system property with the specified key name.

key is the key name for the system property to check.

SecurityException if the calling thread doesn't have permission to access the system property with the specified key name.

checkRead

SecurityManager

public void checkRead(FileDescriptor fd)

This method checks to see whether the calling thread is allowed access to read from the file with the specified file descriptor.

fd is the file descriptor for the file to be checked.

SecurityException if the calling thread doesn't have permission to read from the file.

checkRead

SecurityManager

public void checkRead(String file)

This method checks to see whether the calling thread is allowed access to read from the file with the specified platform-specific filename.

file is the platform-specific filename for the file to be checked.

SecurityException if the calling thread doesn't have permission to read from the file.

checkRead

SecurityManager

public void checkRead(String file, Object context)

This method checks to see whether the specified security context is allowed access to read from the file with the specified platform-specific filename.

file is the platform-specific filename for the file to be checked.

context is the security context for the check.

SecurityException if the specified security context doesn't have permission to read from the file.

checkSetFactory

SecurityManager

public void checkSetFactory()

This method checks to see whether the calling thread is allowed access to set the socket or stream handler factory used by the URL class.

SecurityException if the calling thread doesn't have permission to set the socket or stream handler factory.

checkTopLevelWindow

SecurityManager

public boolean checkTopLevelWindow(Object window)

This method checks to see whether the calling thread is trusted to show the specified top-level window. Note that even if the calling thread isn't trusted to show the window, the window still can be shown with some sort of visual warning.

window is the top-level window to be checked.

TRUE if the calling thread is trusted to show the top-level window; otherwise, returns FALSE.

checkWrite

SecurityManager

public void checkWrite(FileDescriptor fd)

This method checks to see whether the calling thread is allowed access to write to the file with the specified file descriptor.

fd is the file descriptor for the file to be checked.

SecurityException if the calling thread doesn't have permission to write to the file.

checkWrite

SecurityManager

public void checkWrite(String file)

This method checks to see whether the calling thread is allowed access to write to the file with the specified platform-specific filename.

file is the platform-specific filename for the file to be checked.

SecurityException if the calling thread doesn't have permission to write to the file.

classDepth

SecurityManager

protected int classDepth(String name)

This method determines the stack depth of the class with the specified name.

name is the fully qualified name of the class for which to determine the stack depth.

The stack depth of the class, or -1 if the class can't be found in any stack frame.

classLoaderDepth

SecurityManager

protected int classLoaderDepth()

This method determines the stack depth of the most recently executing method of a class defined using a class loader.

The stack depth of the most recently executing method of a class defined using a class loader, or -1 if no method is executing within a class defined by a class loader.

currentClassLoader

SecurityManager

protected ClassLoader currentClassLoader()

This method determines the current class loader on the stack.

The current class loader on the stack, or NULL if no class loader exists on the stack.

getClassContext

SecurityManager

protected Class[] getClassContext()

This method determines the current execution stack, which is an array of classes corresponding to each method call on the stack.

An array of classes corresponding to each method call on the stack.

getInCheck

SecurityManager

public boolean getInCheck()

This method determines whether there is a security check in progress.

TRUE if a security check is in progress; otherwise, returns FALSE.

getSecurityContext

SecurityManager

public Object getSecurityContext()

This method creates a platform-specific security context based on the current runtime environment.

A platform-specific security context based on the current runtime environment.

inClass

SecurityManager

protected boolean inClass(String name)

This method determines whether a method in the class with the specified name is on the execution stack.

name is the name of the class to check.

TRUE if a method in the class is on the execution stack; otherwise, returns FALSE.

inClassLoader

SecurityManager

protected boolean inClassLoader()

This method determines whether a method in a class defined using a class loader is on the execution stack.

TRUE if a method in a class defined using a class loader is on the execution stack; otherwise, returns FALSE.

String

Object

See also: StringBuffer

This class implements a constant string of characters. The String class provides a wide range of support for working with strings of characters. Note that literal string constants are converted automatically to String objects by the Java compiler. The definition for the String class follows:

public final class java.lang.String extends java.lang.Object {
  // Constructors
  public String();
  public String(byte ascii[], int hibyte);
  public String(byte ascii[], int hibyte, int off, int count);
  public String(char value[]);
  public String(char value[], int off, int count);
  public String(String value);
  public String(StringBuffer buffer);

  // Methods
  public char charAt(int index);
  public int compareTo(String anotherString);
  public String concat(String str);
  public static String copyValueOf(char data[]);
  public static String copyValueOf(char data[], int off, int count);
  public boolean endsWith(String suffix);
  public boolean equals(Object anObject);
  public boolean equalsIgnoreCase(String anotherString);
  public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin);
  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin);
  public int hashCode();
  public int indexOf(int ch);
  public int indexOf(int ch, int fromIndex);
  public int indexOf(String str);
  public int indexOf(String str, int fromIndex);
  public String intern();
  public int lastIndexOf(int ch);
  public int lastIndexOf(int ch, int fromIndex);
  public int lastIndexOf(String str);
  public int lastIndexOf(String str, int fromIndex);
  public int length();
  public boolean regionMatches(boolean ignoreCase, int toffset, String other,
    int ooffset, int len);
  public boolean regionMatches(int toffset, String other, int ooffset,
    int len);
  public String replace(char oldChar, char newChar);
  public boolean startsWith(String prefix);
  public boolean startsWith(String prefix, int toffset);
  public String substring(int beginIndex);
  public String substring(int beginIndex, int endIndex);
  public char[] toCharArray();
  public String toLowerCase();
  public String toString();
  public String toUpperCase();
  public String trim();
  public static String valueOf(boolean b);
  public static String valueOf(char c);
  public static String valueOf(char data[]);
  public static String valueOf(char data[], int off, int count);
  public static String valueOf(double d);
  public static String valueOf(float f);
  public static String valueOf(int i);
  public static String valueOf(long l);
  public static String valueOf(Object obj);
}

String

String

public String()

This constructor creates a default string containing no characters.

String

String

public String(byte ascii[], int hibyte)

This constructor creates a string from the specified array of bytes, with the top 8 bits of each string character set to hibyte.

ascii is the byte array that is to be converted to string characters.

hibyte is the high byte value for each character.

String

String

public String(byte ascii[], int hibyte, int off, int count)

This constructor creates a string of length count from the specified array of bytes beginning off bytes into the array, with the top 8 bits of each string character set to hibyte.

ascii is the byte array that is to be converted to string characters.

hibyte is the high byte value for each character.

off is the starting offset into the array of bytes.

count is the number of bytes from the array to convert.

StringIndexOutOfBoundsException if the offset or count for the byte array is invalid.

String

String

public String(char value[])

This constructor creates a string from the specified array of characters.

value is the character array used to initialize the string.

String

String

public String(char value[], int off, int count)

This constructor creates a string of length count from the specified array of characters beginning off bytes into the array.

value is the character array used to initialize the string.

off is the starting offset into the array of characters.

count is the number of characters from the array to use in initializing the string.

StringIndexOutOfBoundsException if the offset or count for the character array is invalid.

String

String

public String(String value)

This constructor creates a new string that is a copy of the specified string.

value is the string by which to initialize this string.

String

String

public String(StringBuffer buffer)

This constructor creates a new string that is a copy of the contents of the specified string buffer.

buffer is the string buffer used to initialize this string.

charAt

String

public char charAt(int index)

This method determines the character at the specified index. Note that string indexes are zero-based, meaning that the first character is located at index 0.

index is the index of the desired character.

The character at the specified index.

StringIndexOutOfBoundsException if the index is out of range.

compareTo

String

public int compareTo(String anotherString)

This method compares this string with the specified string lexicographically.

anotherString is the string to which the comparison is made.

0 if this string is equal to the specified string, a value less than 0 if this string is lexicographically less than the specified string, or a value greater than 0 if this string is lexicographically greater than the specified string.

concat

String

public String concat(String str)

This method concatenates the specified string onto the end of this string.

str is the string to concatenate.

This string, with the specified string concatenated onto the end.

copyValueOf

String

public static String copyValueOf(char data[])

This method converts a character array to an equivalent string by creating a new string and copying the characters into it.

data is the character array to convert to a string.

A string representation of the specified character array.

copyValueOf

String

public static String copyValueOf(char data[], int off, int count)

This method converts a character array to an equivalent string by creating a new string and copying count characters into it beginning at off.

data is the character array to convert to a string.

off is the starting offset into the character array.

count is the number of characters from the array to use in initializing the string.

A string representation of the specified character array beginning at off and of length count.

endsWith

String

public boolean endsWith(String suffix)

This method determines whether this string ends with the specified suffix.

suffix is the suffix to check.

TRUE if this string ends with the specified suffix; otherwise, returns FALSE.

equals

String

public boolean equals(Object anObject)

This method compares the specified object to this string. The equals method returns TRUE only if the specified object is a String object of the same length and contains the same characters as this string.

anObject is the object to compare.

TRUE if the specified object is a String object of the same length and contains the same characters as this string; otherwise, returns FALSE.

equals in class Object.

equalsIgnoreCase

String

public boolean equalsIgnoreCase(String anotherString)

This method compares the specified string to this string, ignoring case.

anotherString is the string to compare.

TRUE if the specified string is of the same length and contains the same characters as this string, ignoring case; otherwise, returns FALSE.

getBytes

String

public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin)

This method copies the lower 8 bits of each character in this string, beginning at srcBegin and ending at srcEnd, into the byte array dst beginning at dstBegin.

srcBegin is the index of the first character in the string to copy.

srcEnd is the index of the last character in the string to copy.

dst is the destination byte array.

dstBegin is the starting offset into the byte array.

getChars

String

public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

This method copies each character in this string, beginning at srcBegin and ending at srcEnd, into the character array dst beginning at dstBegin.

srcBegin is the index of the first character in the string to copy.

srcEnd is the index of the last character in the string to copy.

dst is the destination character array.

dstBegin is the starting offset into the character array.

StringIndexOutOfBoundsException if there is an invalid index in the buffer.

hashCode

String

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

indexOf

String

public int indexOf(int ch)

This method determines the index of the first occurrence of the specified character in this string.

ch is the character for which to search.

The index of the first occurrence of the specified character, or -1 if the character doesn't occur.

indexOf

String

public int indexOf(int ch, int fromIndex)

This method determines the index of the first occurrence of the specified character in this string, beginning at fromIndex.

ch is the character for which to search.

fromIndex is the index from which to start the search.

The index of the first occurrence of the specified character beginning at fromIndex, or if the character doesn't occur.

indexOf

String

public int indexOf(String str)

This method determines the index of the first occurrence of the specified substring in this string.

str is the substring for which to search.

The index of the first occurrence of the specified substring, or -1 if the substring doesn't occur.

indexOf

String

public int indexOf(String str, int fromIndex)

This method determines the index of the first occurrence of the specified substring in this string, beginning at fromIndex.

str is the substring for which to search.

fromIndex is the index from which to start the search.

The index of the first occurrence of the specified substring beginning at fromIndex, or if the substring doesn't occur.

intern

String

public String intern()

This method determines a string that is equal to this string but is guaranteed to be from a pool of unique strings.

A string that is equal to this string but is guaranteed to be from a pool of unique strings.

lastIndexOf

String

public int lastIndexOf(int ch)

This method determines the index of the last occurrence of the specified character in this string.

ch is the character for which to search.

The index of the last occurrence of the specified character, or -1 if the character doesn't occur.

lastIndexOf

String

public int lastIndexOf(int ch, int fromIndex)

This method determines the index of the last occurrence of the specified character in this string, beginning at fromIndex.

ch is the character for which to search.

fromIndex is the index from which to start the search.

The index of the last occurrence of the specified character beginning at fromIndex, or -1 if the character doesn't occur.

lastIndexOf

String

public int lastIndexOf(String str)

This method determines the index of the last occurrence of the specified substring in this string.

str is the substring for which to search.

The index of the last occurrence of the specified substring, or -1 if the substring doesn't occur.

lastIndexOf

String

public int lastIndexOf(String str, int fromIndex)

This method determines the index of the last occurrence of the specified substring in this string, beginning at fromIndex.

str is the substring for which to search.

fromIndex is the index from which to start the search.

The index of the last occurrence of the specified substring beginning at fromIndex, or -1 if the substring doesn't occur.

length

String

public int length()

This method determines the length of this string, which is the number of Unicode characters in the string.

The length of this string.

regionMatches

String

public boolean regionMatches(boolean ignoreCase, int toffset, String other, int Âooffset, int len)

This method determines whether a substring of this string matches a substring of the specified string, with an option for ignoring case.

ignoreCase is a Boolean value specifying whether case is ignored; a value of TRUE means that case is ignored, whereas a value of FALSE means that case isn't ignored.

toffset is the index from which to start the substring for this string.

other is the other string to compare.

ooffset is the index from which to start the substring for the string to compare.

len is the number of characters to compare.

TRUE if the substring of this string matches the substring of the specified string; otherwise, returns FALSE.

regionMatches

String

public boolean regionMatches(int toffset, String other, int ooffset, int len)

This method determines whether a substring of this string matches a substring of the specified string.

toffset is the index from which to start the substring for this string.

other is the other string to compare.

ooffset is the index from which to start the substring for the string to compare.

len is the number of characters to compare.

TRUE if the substring of this string matches the substring of the specified string; otherwise, returns FALSE.

replace

String

public String replace(char oldChar, char newChar)

This method replaces all occurrences of oldChar in this string with newChar.

oldChar is the old character to replace.

newChar is the new character to take its place.

This string, with all occurrences of oldChar replaced with newChar.

startsWith

String

public boolean startsWith(String prefix)

This method determines whether this string starts with the specified prefix.

prefix is the prefix to check.

TRUE if this string starts with the specified prefix; otherwise, returns FALSE.

startsWith

String

public boolean startsWith(String prefix, int toffset)

This method determines whether this string starts with the specified prefix, beginning at toffset.

prefix is the prefix to check.

toffset is the index from which to start the search.

TRUE if this string starts with the specified prefix beginning at toffset; otherwise, returns FALSE.

substring

String

public String substring(int beginIndex)

This method determines the substring of this string, beginning at beginIndex.

beginIndex is the beginning index of the substring, inclusive.

The substring of this string, beginning at beginIndex.

StringIndexOutOfBoundsException if beginIndex is out of range.

substring

String

public String substring(int beginIndex, int endIndex)

This method determines the substring of this string, beginning at beginIndex and ending at endIndex.

beginIndex is the beginning index of the substring, inclusive.

endIndex is the end index of the substring, exclusive.

The substring of this string, beginning at beginIndex and ending at endIndex.

StringIndexOutOfBoundsException if beginIndex or endIndex is out of range.

toCharArray

String

public char[] toCharArray()

This method converts this string to a character array by creating a new array and copying each character of the string to it.

A character array representing this string.

toLowerCase

String

public String toLowerCase()

This method converts all the characters in this string to lowercase.

This string, with all the characters converted to lowercase.

toString

String

public String toString()

This method returns this string.

This string itself.

toString in class Object.

toUpperCase

String

public String toUpperCase()

This method converts all the characters in this string to uppercase.

This string, with all the characters converted to uppercase.

trim

String

public String trim()

This method trims leading and trailing whitespace from this string.

This string, with leading and trailing whitespace removed.

valueOf

String

public static String valueOf(boolean b)

This method creates a string representation of the specified Boolean value. If the Boolean value is TRUE, the string "true" is returned; otherwise, the string "false" is returned.

b is the Boolean value from which to get the string representation.

A string representation of the specified Boolean value.

valueOf

String

public static String valueOf(char c)

This method creates a string representation of the specified character value.

c is the character value from which to get the string representation.

A string representation of the specified character value.

valueOf

String

public static String valueOf(char data[])

This method creates a string representation of the specified character array.

data is the character array from which to get the string representation.

A string representation of the specified character array.

valueOf

String

public static String valueOf(char data[], int off, int count)

This method creates a string representation of length count from the specified array of characters, beginning off bytes into the array.

data is the character array from which to get the string representation.

off is the starting offset into the array of characters.

count is the number of characters from the array to use in initializing the string.

A string representation of the specified character array.

valueOf

String

public static String valueOf(double d)

This method creates a string representation of the specified double value.

d is the double value from which to get the string representation.

A string representation of the specified double value.

valueOf

String

public static String valueOf(float f)

This method creates a string representation of the specified float value.

f is the float value from which to get the string representation.

A string representation of the specified float value.

valueOf

String

public static String valueOf(int i)

This method creates a string representation of the specified integer value.

i is the integer value from which to get the string representation.

A string representation of the specified integer value.

valueOf

String

public static String valueOf(long l)

This method creates a string representation of the specified long value.

l is the long value from which to get the string representation.

A string representation of the specified long value.

valueOf

String

public static String valueOf(Object obj)

This method creates a string representation of the specified object. Note that the string representation is the same as that returned by the toString method of the object.

obj is the object from which to get the string representation.

A string representation of the specified object value, or the string "null" if the object is null.

StringBuffer

Object

See also: String

This class implements a variable string of characters. The StringBuffer class provides a wide range of append and insert methods, along with some other support methods for getting information about the string buffer. Note that the StringBuffer class is synchronized appropriately so that it can be used by multiple threads. The definition for the StringBuffer class follows:

public class java.lang.StringBuffer extends java.lang.Object {
  // Constructors
  public StringBuffer();
  public StringBuffer(int length);
  public StringBuffer(String str);

  // Methods
  public StringBuffer append(boolean b);
  public StringBuffer append(char c);
  public StringBuffer append(char str[]);
  public StringBuffer append(char str[], int off, int len);
  public StringBuffer append(double d);
  public StringBuffer append(float f);
  public StringBuffer append(int i);
  public StringBuffer append(long l);
  public StringBuffer append(Object obj);
  public StringBuffer append(String str);
  public int capacity();
  public char charAt(int index);
  public void ensureCapacity(int minimumCapacity);
  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin);
  public StringBuffer insert(int off, boolean b);
  public StringBuffer insert(int off, char c);
  public StringBuffer insert(int off, char str[]);
  public StringBuffer insert(int off, double d);
  public StringBuffer insert(int off, float f);
  public StringBuffer insert(int off, int i);
  public StringBuffer insert(int off, long l);
  public StringBuffer insert(int off, Object obj);
  public StringBuffer insert(int off, String str);
  public int length();
  public StringBuffer reverse();
  public void setCharAt(int index, char ch);
  public void setLength(int newLength);
  public String toString();
}

StringBuffer

-

StringBuffer

public StringBuffer()

This constructor creates a default string buffer with no characters.

StringBuffer

-

StringBuffer

public StringBuffer(int length)

This constructor creates a string buffer with the specified length.

length is the initial length of the string buffer.

StringBuffer

-

StringBuffer

public StringBuffer(String str)

This constructor creates a string buffer with the specified initial string value.

str is the initial string value of the string buffer.

append

-

StringBuffer

public StringBuffer append(boolean b)

This method appends the string representation of the specified Boolean value to the end of this string buffer.

b is the Boolean value to be appended.

This string buffer, with the Boolean appended.

append

-

StringBuffer

public StringBuffer append(char c)

This method appends the string representation of the specified character value to the end of this string buffer.

c is the character value to be appended.

This string buffer, with the character appended.

append

-

StringBuffer

public StringBuffer append(char str[])

This method appends the string representation of the specified character array to the end of this string buffer.

str is the character array to be appended.

This string buffer, with the character array appended.

append

-

StringBuffer

public StringBuffer append(char str[], int off, int len)

This method appends the string representation of the specified character subarray to the end of this string buffer.

str is the character array to be appended.

off is the starting offset into the character array to append.

len is the number of characters to append.

This string buffer, with the character subarray appended.

append

-

StringBuffer

public StringBuffer append(double d)

This method appends the string representation of the specified double value to the end of this string buffer.

d is the double value to be appended.

This string buffer, with the double appended.

append

-

StringBuffer

public StringBuffer append(float f)

This method appends the string representation of the specified float value to the end of this string buffer.

f is the float value to be appended.

This string buffer, with the float appended.

append

-

StringBuffer

public StringBuffer append(int i)

This method appends the string representation of the specified integer value to the end of this string buffer.

i is the integer value to be appended.

This string buffer, with the integer appended.

append

-

StringBuffer

public StringBuffer append(long l)

This method appends the string representation of the specified long value to the end of this string buffer.

l is the long value to be appended.

This string buffer, with the long appended.

append

-

StringBuffer

public StringBuffer append(Object obj)

This method appends the string representation of the specified object to the end of this string buffer. Note that the string representation is the same as that returned by the toString method of the object.

obj is the object to be appended.

This string buffer, with the object appended.

append

-

StringBuffer

public StringBuffer append(String str)

This method appends the specified string to the end of this string buffer.

str is the string to be appended.

This string buffer, with the string appended.

capacity

-

StringBuffer

public int capacity()

This method determines the capacity of this string buffer, which is the amount of character storage currently allocated in the string buffer.

The capacity of this string buffer.

charAt

-

StringBuffer

public char charAt(int index)

This method determines the character at the specified index. Note that string buffer indexes are zero-based, meaning that the first character is located at index 0.

index is the index of the desired character.

The character at the specified index.

StringIndexOutOfBoundsException if the index is out of range.

ensureCapacity

-

StringBuffer

public void ensureCapacity(int minimumCapacity)

This method ensures that the capacity of this string buffer is at least equal to the specified minimum.

minimumCapacity is the minimum desired capacity.

getChars

-

StringBuffer

public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)

This method copies each character in this string buffer, beginning at srcBegin and ending at srcEnd, into the character array dst beginning at dstBegin.

srcBegin is the index of the first character in the string buffer to copy.

srcEnd is the index of the last character in the string buffer to copy.

dst is the destination character array.

dstBegin is the starting offset into the character array.

StringIndexOutOfBoundsException if there is an invalid index in the buffer.

insert

-

StringBuffer

public StringBuffer insert(int off, boolean b)

This method inserts the string representation of the specified Boolean value at the specified offset of this string buffer.

off is the offset at which to insert the Boolean.

b is the Boolean value to be inserted.

This string buffer, with the Boolean inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, char c)

This method inserts the string representation of the specified character value at the specified offset of this string buffer.

off is the offset at which to insert the character.

c is the character value to be inserted.

This string buffer, with the character inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, char str[])

This method inserts the string representation of the specified character array at the specified offset of this string buffer.

off is the offset at which to insert the character array.

str is the character array to be inserted.

This string buffer, with the character array inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, double d)

This method inserts the string representation of the specified double value at the specified offset of this string buffer.

off is the offset at which to insert the double.

d is the double value to be inserted.

This string buffer, with the double inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, float f)

This method inserts the string representation of the specified float value at the specified offset of this string buffer.

off is the offset at which to insert the float.

f is the float value to be inserted.

This string buffer, with the float inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, int i)

This method inserts the string representation of the specified integer value at the specified offset of this string buffer.

off is the offset at which to insert the integer.

i is the integer value to be inserted.

This string buffer, with the integer inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, long l)

This method inserts the string representation of the specified long value at the specified offset of this string buffer.

off is the offset at which to insert the long.

l is the long value to be inserted.

This string buffer, with the long inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, Object obj)

This method inserts the string representation of the specified object at the specified offset of this string buffer. Note that the string representation is the same as that returned by the toString method of the object.

off is the offset at which to insert the object.

obj is the object to be inserted.

This string buffer, with the object inserted.

StringIndexOutOfBoundsException if the offset is invalid.

insert

-

StringBuffer

public StringBuffer insert(int off, String str)

This method inserts the specified string at the specified offset of this string buffer.

off is the offset at which to insert the string.

str is the string to be inserted.

This string buffer, with the string inserted.

StringIndexOutOfBoundsException if the offset is invalid.

length

-

StringBuffer

public int length()

This method determines the length of this string buffer, which is the actual number of characters stored in the buffer.

The length of this string buffer.

reverse

-

StringBuffer

public StringBuffer reverse()

This method reverses the character sequence in this string buffer.

This string buffer, with the characters reversed.

setCharAt

-

StringBuffer

public void setCharAt(int index, char ch)

This method changes the character at the specified index in this string to the specified
character.

index is the index of the character to change.

ch is the new character.

StringIndexOutOfBoundsException if the index is invalid.

setLength

-

StringBuffer

public void setLength(int newLength)

This method explicitly sets the length of this string buffer. If the length is reduced, characters are lost; if the length is increased, new characters are set to 0 (NULL). The new length must be greater than or equal to 0.

newLength is the new length of the string buffer.

StringIndexOutOfBoundsException if the length is invalid.

toString

-

StringBuffer

public String toString()

This method determines a constant string representation of this string buffer.

The constant string representation of this string buffer.

toString in class Object.

System

Object

This class provides a platform-independent means of interacting with the Java runtime system. The System class provides support for standard input, standard output, and standard error streams, along with providing access to system properties, among other things. Note that the System class cannot be instantiated or subclassed because all its methods and variables are static. The definition for the System class follows:

public final class java.lang.System extends java.lang.Object {
  // Member Variables
  public static PrintStream err;
  public static InputStream in;
  public static PrintStream out;

  // Methods
  public static void arraycopy(Object src, int src_position, Object dst,
    int dst_position, int length);
  public static long currentTimeMillis();
  public static void exit(int status);
  public static void gc();
  public static Properties getProperties();
  public static String getProperty(String key);
  public static String getProperty(String key, String def);
  public static SecurityManager getSecurityManager();
  public static void load(String pathname);
  public static void loadLibrary(String libname);
  public static void runFinalization();
  public static void setProperties(Properties props);
  public static void setSecurityManager(SecurityManager s);
}

Member Variables

public static PrintStream err

This is the standard error stream, which is used for printing error information. Typically, this stream corresponds to display output, because it is important that the user see the error information.

public static InputStream in

This is the standard input stream, which is used for reading character data. Typically, this stream corresponds to keyboard input or another input source specified by the host environment or user.

public static PrintStream out

This is the standard output stream, which is used for printing character data. Typically, this stream corresponds to display output or another output destination specified by the host environment or user.

arraycopy

-

System

public static void arraycopy(Object src, int src_position, Object dst, int Âdst_position, int length)

This method copies len array elements from the src array, beginning at src_position, to the dst array, beginning at dst_position. Both src and dst must be array objects. Note that arraycopy does not allocate memory for the destination array; the memory already must be allocated.

src is the source array from which to copy data.

src_position is the start position in the source array.

dst is the destination array to which data is copied.

dst_position is the start position in the destination array.

length is the number of array elements to be copied.

ArrayIndexOutOfBoundsException if the copy would cause data to be accessed outside of array bounds.

ArrayStoreException if an element in the source array could not be stored in the destination array due to a type mismatch.

currentTimeMillis

System

public static long currentTimeMillis()

This method determines the current UTC time relative to midnight, January 1, 1970 UTC, in milliseconds.

The current UTC time relative to midnight, January 1, 1970 UTC, in milliseconds.

exit

-

System

public static void exit(int status)

This method exits the Java runtime system (virtual machine) with the specified integer exit status. Note that because exit kills the runtime system, it never returns. This method simply calls the exit method in the Runtime class.

status is the integer exit status; this should be set to nonzero if this is an abnormal exit.

SecurityException if the current thread cannot exit with the specified exit status.

gc

-

System

public static void gc()

This method invokes the Java garbage collector to clean up any objects that no longer are needed, usually resulting in more free memory. This method simply calls the gc method in the Runtime class.

getProperties

-

System

public static Properties getProperties()

This method determines the current system properties. Table 32.2 lists all the system properties guaranteed to be supported.

Table 32.2. Supported getProperties system properties.

PropertyDescription
java.version Java version number
java.vendor Java vendor-specific string
java.vendor.url Java vendor URL
java.home Java installation directory
java.class.version Java class format version number
java.class.path Java CLASSPATH environment variable
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator
path.separator Path separator
line.separator Line separator
user.name User's account name
user.home User's home directory
user.dir User's current working directory

The current system properties.

SecurityException if the current thread cannot access the system properties.

getProperty

-

System

public static String getProperty(String key)

This method determines the system property with the specified key name.

key is the key name of the system property.

The system property with the specified key name.

SecurityException if the current thread cannot access the system property.

getProperty

-

System

public static String getProperty(String key, String def)

This method determines the system property with the specified key name; it returns the specified default property value if the key isn't found.

key is the key name of the system property.

def is the default property value to use if the key isn't found.

The system property with the specified key name, or the specified default property value if the key isn't found.

SecurityException if the current thread cannot access the system property.

getSecurityManager

-

System

public static SecurityManager getSecurityManager()

This method gets the security manager for the Java program, or NULL if none exists.

The security manager for the Java program, or NULL if none exists.

load

-

System

public static void load(String pathname)

This method loads the dynamic library with the specified complete path name. This method simply calls the load method in the Runtime class.

pathname is the path name of the library to load.

UnsatisfiedLinkError if the library doesn't exist.

SecurityException if the current thread can't load the library.

loadLibrary

-

System

public static void loadLibrary(String libname)

This method loads the dynamic library with the specified library name. Note that the mapping from library name to a specific filename is performed in a platform-specific manner. This method simply calls the loadLibrary method in the Runtime class.

libname is the name of the library to load.

UnsatisfiedLinkError if the library doesn't exist.

SecurityException if the current thread can't load the library.

runFinalization

-

System

public static void runFinalization()

This method explicitly causes the finalize methods of any discarded objects to be called. Typically, the finalize methods of discarded objects are automatically called asynchronously when the garbage collector cleans up the objects. You can use runFinalization to have the finalize methods called synchronously. This method simply calls the runFinalization method in the Runtime class.

setProperties

-

System

public static void setProperties(Properties props)

This method sets the system properties to the specified properties.

props specifies the new properties to be set.

setSecurityManager

-

System

public static void setSecurityManager(SecurityManager s)

This method sets the security manager to the specified security manager. Note that the security manager can be set only once for a Java program.

s is the new security manager to be set.

SecurityException if the security manager already has been set.

Thread

Object

Runnable

See also: ThreadGroup

This class provides the overhead necessary to manage a single thread of execution within a process. The Thread class is the basis for multithreaded programming in Java. The definition for the Thread class follows:

public class java.lang.Thread extends java.lang.Object
  implements java.lang.Runnable {
  // Member Constants
  public final static int MAX_PRIORITY;
  public final static int MIN_PRIORITY;
  public final static int NORM_PRIORITY;

  // Constructors
  public Thread();
  public Thread(Runnable target);
  public Thread(Runnable target, String name);
  public Thread(String name);
  public Thread(ThreadGroup group, Runnable target);
  public Thread(ThreadGroup group, Runnable target, String name);
  public Thread(ThreadGroup group, String name);

  // Methods
  public static int activeCount();
  public void checkAccess();
  public int countStackFrames();
  public static Thread currentThread();
  public void destroy();
  public static void dumpStack();
  public static int enumerate(Thread list[]);
  public final String getName();
  public final int getPriority();
  public final ThreadGroup getThreadGroup();
  public void interrupt();
  public static boolean interrupted();
  public final boolean isAlive();
  public final boolean isDaemon();
  public boolean isInterrupted();
  public final void join();
  public final void  join(long timeout);
  public final void join(long timeout, int nanos);
  public final void resume();
  public void run();
  public final void setDaemon(boolean daemon);
  public final void setName(String name);
  public final void setPriority(int newPriority);
  public static void sleep(long millis);
  public static void sleep(long millis, int nanos);
  public void start();
  public final void stop();
  public final void  stop(Throwable obj);
  public final void suspend();
  public String toString();
  public static void yield();
}

Member Constants

public final static int MAX_PRIORITY

This is a constant representing the maximum priority a thread can have, which is set to 10.

public final static int MIN_PRIORITY

This is a constant representing the minimum priority a thread can have, which is set to 1.

public final static int NORM_PRIORITY

This is a constant representing the normal (default) priority for a thread, which is set to 5.

Thread

-

Thread

-

public Thread()

This constructor creates a default thread. Note that threads created with this constructor must have overridden their run method to actually do anything.

Thread

-

Thread

-

public Thread(Runnable target)

This constructor creates a thread that uses the run method of the specified runnable.

target is the object with the run method used by the thread.

Thread

-

Thread

-

public Thread(ThreadGroup group, Runnable target)

This constructor creates a thread belonging to the specified thread group that uses the run method of the specified runnable.

group is the thread group of which the thread is to be a member.

target is the object with the run method used by the thread.

Thread

-

Thread

-

public Thread(String name)

This constructor creates a thread with the specified name.

name is the name of the new thread.

Thread

-

Thread

-

public Thread(ThreadGroup group, String name)

This constructor creates a thread belonging to the specified thread group with the specified name.

group is the thread group of which the thread is to be a member.

name is the name of the new thread.

Thread

-

Thread

-

public Thread(Runnable target, String name)

This constructor creates a thread with the specified name that uses the run method of the specified runnable.

target is the object with the run method used by the thread.

name is the name of the new thread.

Thread

-

Thread

-

public Thread(ThreadGroup group, Runnable target, String name)

This constructor creates a thread belonging to the specified thread group with the specified name that uses the run method of the specified runnable.

group is the thread group of which the thread is to be a member.

target is the object with the run method used by the thread.

name is the name of the new thread.

activeCount

-

Thread

-

public static int activeCount()

This method determines the number of active threads in this thread's thread group.

The number of active threads in this thread's thread group.

checkAccess

-

Thread

-

public void checkAccess()

This method checks to see whether the currently running thread is allowed access to this thread.

SecurityException if the calling thread doesn't have access to this thread.

countStackFrames

-

Thread

-

public int countStackFrames()

This method determines the number of stack frames in this thread. Note that the thread must be suspended in order to use this method.

The number of stack frames in this thread.

IllegalThreadStateException if the thread is not suspended.

currentThread

-

Thread

-

public static Thread currentThread()

This method determines the currently running thread.

The currently running thread.

destroy

-

Thread

-

public void destroy()

This method destroys this thread without performing any cleanup, meaning that any monitors locked by the thread remain locked. Note that this method should be used only as a last resort for destroying a thread.

dumpStack

-

Thread

-

public static void dumpStack()

This method prints a stack trace for this thread. Note that this method is useful only for debugging.

enumerate

-

Thread

-

public static int enumerate(Thread list[])

This method fills the specified array with references to every active thread in this thread's thread group.

list is an array to hold the enumerated threads.

The number of threads added to the array.

getName

-

Thread

-

public final String getName()

This method determines the name of this thread.

The name of this thread.

getPriority

-

Thread

-

public final int getPriority()

This method determines the priority of this thread.

The priority of this thread.

getThreadGroup

-

Thread

-

public final ThreadGroup getThreadGroup()

This method determines the thread group for this thread.

The thread group for this thread.

interrupt

-

Thread

-

public void interrupt()

This method interrupts this thread.

interrupted

-

Thread

-

public static boolean interrupted()

This method determines whether this thread has been interrupted.

TRUE if the thread has been interrupted; otherwise, returns FALSE.

isAlive

-

Thread

-

public final boolean isAlive()

This method determines whether this thread is active. An active thread is a thread that has been started and has not yet stopped.

TRUE if the thread is alive; otherwise, returns FALSE.

isDaemon

-

Thread

-

public final boolean isDaemon()

This method determines whether this thread is a daemon thread. A daemon thread is a background thread that is owned by the runtime system rather than a specific process.

TRUE if the thread is a daemon thread; otherwise, returns FALSE.

isInterrupted

-

Thread

-

public boolean isInterrupted()

This method determines whether this thread has been interrupted.

TRUE if the thread has been interrupted; otherwise, returns FALSE.

join

-

Thread

-

public final void join() throws InterruptedException

This method causes the current thread to wait indefinitely until it dies.

InterruptedException if another thread has interrupted this thread.

join

-

Thread

-

public final void join(long timeout) throws InterruptedException

This method causes the current thread to wait until it dies, or until the specified timeout period has elapsed.

timeout is the maximum timeout period to wait, in milliseconds.

InterruptedException if another thread has interrupted this thread.

join

-

Thread

-

public final void join(long timeout, int nanos) throws InterruptedException

This method causes the current thread to wait until it dies, or until the specified timeout period has elapsed. The timeout period, in this case, is the addition of the timeout and nanos parameters, which provide finer control over the timeout period.

timeout is the maximum timeout period to wait, in milliseconds.

nanos is the additional time for the timeout period, in nanoseconds.

InterruptedException if another thread has interrupted this thread.

resume

-

Thread

-

public final void resume()

This method resumes this thread's execution if it has been suspended.

SecurityException if the current thread doesn't have access to this thread.

run

-

Thread

-

public void run()

This method is the body of the thread, which performs the actual work of the thread. The run method is called when the thread is started. The run method is overridden in a derived Thread class or implemented in a class implementing the Runnable interface.

setDaemon

-

Thread

-

public final void setDaemon(boolean daemon)

This method sets this thread as a daemon thread or a user thread based on the specified Boolean value. Note that the thread must be inactive in order to use this method.

daemon is a Boolean value that determines whether the thread is a daemon thread.

IllegalThreadStateException if the thread is active.

setName

-

Thread

-

public final void setName(String name)

This method sets the name of this thread.

name is the new name of the thread.

SecurityException if the current thread doesn't have access to this thread.

setPriority

-

Thread

-

public final void setPriority(int newPriority)

This method sets the priority of this thread.

newPriority is the new priority of the thread.

IllegalArgumentException if the priority is not within the range MIN_PRIORITY to MAX_PRIORITY.

SecurityException if the current thread doesn't have access to this thread.

sleep

-

Thread

-

public static void sleep(long millis) throws InterruptedException

This method causes the current thread to sleep for the specified length of time, in milliseconds.

millis is the length of time to sleep, in milliseconds.

InterruptedException if another thread has interrupted this thread.

sleep

-

Thread

-

public static void sleep(long millis, int nanos) throws InterruptedException

This method causes the current thread to sleep for the specified length of time. The length of time, in this case, is the addition of the millis and nanos parameters, which provide finer control over the sleep time.

millis is the length of time to sleep, in milliseconds.

nanos is the additional time for the sleep time, in nanoseconds.

InterruptedException if another thread has interrupted this thread.

start

-

Thread

-

public void start()

This method starts this thread, causing the run method to be executed.

IllegalThreadStateException if the thread already was running.

stop

-

Thread

-

public final void stop()

This method abnormally stops this thread, causing it to throw a ThreadDeath object. You can catch the ThreadDeath object to perform cleanup, but there is rarely a need to do so.

SecurityException if the current thread doesn't have access to this thread.

stop

-

Thread

-

public final synchronized void stop(Throwable obj)

This method abnormally stops this thread, causing it to throw the specified object. Note that this version of stop should be used only in very rare situations.

obj is the object to be thrown.

SecurityException if the current thread doesn't have access to this thread.

suspend

-

Thread

-

public final void suspend()

This method suspends the execution of this thread.

SecurityException if the current thread doesn't have access to this thread.

toString

-

Thread

-

public String toString()

This method determines a string representation of this thread, which includes the thread's name, priority, and thread group.

A string representation of this thread.

toString in class Object.

yield

-

Thread

-

public static void yield()

This method causes the currently executing thread to yield so that other threads can execute.

ThreadGroup

Object

See also: Thread

This class implements a thread group, which is a set of threads that can be manipulated as one. Thread groups also can contain other thread groups, resulting in a thread hierarchy. The definition for the ThreadGroup class follows:

public class java.lang.ThreadGroup extends java.lang.Object {
  // Constructors
  public ThreadGroup(String name);
  public ThreadGroup(ThreadGroup parent, String name);

  // Methods
  public int activeCount();
  public int activeGroupCount();
  public final void checkAccess();
  public final void destroy();
  public int enumerate(Thread list[]);
  public int enumerate(Thread list[], boolean recurse);
  public int enumerate(ThreadGroup list[]);
  public int enumerate(ThreadGroup list[], boolean recurse);
  public final int getMaxPriority();
  public final String getName();
  public final ThreadGroup getParent();
  public final boolean isDaemon();
  public void list();
  public final boolean parentOf(ThreadGroup g);
  public final void resume();
  public final void setDaemon(boolean daemon);
  public final void  setMaxPriority(int pri);
  public final synchronized void stop();
  public final synchronized void suspend();
  public String toString();
  public void uncaughtException(Thread t, Throwable e);
}

ThreadGroup

-

ThreadGroup

-

public ThreadGroup(String name)

This constructor creates a thread group with the specified name. The newly created thread group belongs to the thread group of the current thread.

name is the name of the new thread group.

ThreadGroup

-

ThreadGroup

-

public ThreadGroup(ThreadGroup parent, String name)

This constructor creates a thread group with the specified name that belongs to the specified parent thread group.

parent is the parent thread group.

name is the name of the new thread group.

NullPointerException if the specified thread group is NULL.

SecurityException if the current thread cannot create a thread in the specified thread group.

activeCount

-

ThreadGroup

-

public int activeCount()

This method determines the number of active threads in this thread group or in any other thread group that has this thread group as an ancestor.

The number of active threads in this thread group or in any other thread group that has this thread group as an ancestor.

activeGroupCount

-

ThreadGroup

-

public int activeGroupCount()

This method determines the number of active thread groups that have this thread group as an ancestor.

The number of active thread groups that have this thread group as an ancestor.

checkAccess

-

ThreadGroup

-

public final void checkAccess()

This method checks to see whether the currently running thread is allowed access to this thread group.

SecurityException if the calling thread doesn't have access to this thread group.

destroy

-

ThreadGroup

-

public final void destroy()

This method destroys this thread group and all its subgroups. Note that the thread group must be empty, meaning that all threads that belonged to the group have since stopped.

IllegalThreadStateException if the thread group is not empty or if it already was destroyed.

SecurityException if the calling thread doesn't have access to this thread group.

enumerate

-

ThreadGroup

-

public int enumerate(Thread list[])

This method fills the specified array with references to every active thread in this thread group.

list is an array to hold the enumerated threads.

The number of threads added to the array.

enumerate

-

ThreadGroup

-

public int enumerate(Thread list[], boolean recurse)

This method fills the specified array with references to every active thread in this thread group. If the recurse parameter is set to TRUE, all the active threads belonging to subgroups of this thread also are added to the array.

list is an array to hold the enumerated threads.

recurse is a Boolean value specifying whether to recursively enumerate active threads in subgroups.

The number of threads added to the array.

enumerate

-

ThreadGroup

-

public int enumerate(ThreadGroup list[])

This method fills the specified array with references to every active subgroup in this thread group.

list is an array to hold the enumerated thread groups.

The number of thread groups added to the array.

enumerate

-

ThreadGroup

-

public int enumerate(ThreadGroup list[], boolean recurse)

This method fills the specified array with references to every active subgroup in this thread group. If the recurse parameter is set to TRUE, all the active thread groups belonging to subgroups of this thread also are added to the array.

list is an array to hold the enumerated thread groups.

recurse is a Boolean value specifying whether to recursively enumerate active thread groups in subgroups.

The number of thread groups added to the array.

getMaxPriority

-

ThreadGroup

-

public final int getMaxPriority()

This method determines the maximum priority of this thread group. Note that threads in this thread group cannot have a higher priority than the maximum priority.

The maximum priority of this thread group.

getName

-

ThreadGroup

-

public final String getName()

This method determines the name of this thread group.

The name of this thread group.

getParent

-

ThreadGroup

-

public final ThreadGroup getParent()

This method determines the parent of this thread group.

The parent of this thread group.

isDaemon

-

ThreadGroup

-

public final boolean isDaemon()

This method determines whether this thread group is a daemon thread group. A daemon thread group is destroyed automatically when all its threads finish executing.

TRUE if the thread group is a daemon thread group; otherwise, returns FALSE.

list

-

ThreadGroup

-

public void list()

This method prints information about this thread group to standard output, including the active threads in the group. Note that this method is useful only for debugging.

parentOf

-

ThreadGroup

-

public final boolean parentOf(ThreadGroup g)

This method checks to see whether this thread group is a parent or ancestor of the specified thread group.

g is the thread group to be checked.

TRUE if this thread group is the parent or ancestor of the specified thread group; otherwise, returns FALSE.

resume

-

ThreadGroup

-

public final void resume()

This method resumes execution of all the threads in this thread group that have been suspended.

SecurityException if the current thread doesn't have access to this thread group or any of its threads.

setDaemon

-

ThreadGroup

-

public final void setDaemon(boolean daemon)

This method sets this thread group as a daemon thread group or a user thread group based on the specified Boolean value. A daemon thread group is destroyed automatically when all its threads finish executing.

daemon is a Boolean value that determines whether the thread group is a daemon thread group.

SecurityException if the current thread doesn't have access to this thread group.

setMaxPriority

-

ThreadGroup

-

public final void setMaxPriority(int pri)

This method sets the maximum priority of this thread group.

pri is the new maximum priority of the thread group.

SecurityException if the current thread doesn't have access to this thread group.

stop

-

ThreadGroup

-

public final synchronized void stop()

This method stops all the threads in this thread group and in all its subgroups.

SecurityException if the current thread doesn't have access to this thread group, any of its threads, or threads in subgroups.

suspend

-

ThreadGroup

-

public final synchronized void suspend()

This method suspends all the threads in this thread group and in all its subgroups.

SecurityException if the current thread doesn't have access to this thread group, any of its threads, or threads in subgroups.

toString

-

ThreadGroup

-

public String toString()

This method determines a string representation of this thread group.

A string representation of this thread group.

toString in class Object.

uncaughtException

-

ThreadGroup

-

public void uncaughtException(Thread t, Throwable e)

This method is called when a thread in this thread group exits because of an uncaught exception. You can override this method to provide specific handling of uncaught exceptions.

t is the thread that is exiting.

e is the uncaught exception.

Throwable

Object

This class provides the core functionality for signaling when exceptional conditions occur. All errors and exceptions in the Java system are derived from Throwable. The Throwable class contains a snapshot of the execution stack for helping to track down why exceptional conditions occur. The definition for the Throwable class follows:

public class java.lang.Throwable extends java.lang.Object {
  // Constructors
  public Throwable();
  public Throwable(String message);

  // Methods
  public Throwable fillInStackTrace();
  public String getMessage();
  public void printStackTrace();
  public void printStackTrace(PrintStream s);
  public String toString();
}

Throwable

-

Throwable

public Throwable()

This constructor creates a default throwable with no detail message; the stack trace is filled in automatically.

Throwable

-

Throwable

public Throwable(String message)

This constructor creates a throwable with the specified detail message; the stack trace is filled in automatically.

message is the detail message.

fillInStackTrace

-

Throwable

public Throwable fillInStackTrace()

This method fills in the execution stack trace. Note that this method is useful only when rethrowing this throwable.

This throwable.

getMessage

-

Throwable

public String getMessage()

This method determines the detail message of this throwable.

The detail message of this throwable.

printStackTrace

-

Throwable

public void printStackTrace()

This method prints this throwable and its stack trace to the standard error stream.

printStackTrace

-

Throwable

public void printStackTrace(PrintStream s)

This method prints this throwable and its stack trace to the specified print stream.

s is the print stream to which the stack will be printed.

toString

-

Throwable

public String toString()

This method determines a string representation of this throwable.

A string representation of this throwable.

toString in class Object.

ArithmeticException

RuntimeException

This exception class signals that an exceptional arithmetic condition has occurred, such as a division by zero. The definition for the ArithmeticException class follows:

public class java.lang.ArithmeticException
  extends java.lang.RuntimeException {
  // Constructors
  public ArithmeticException();
  public ArithmeticException(String s);
}

ArithmeticException

-

ArithmeticException

public ArithmeticException()

This constructor creates a default arithmetic exception with no detail message.

ArithmeticException

-

ArithmeticException

public ArithmeticException(String s)

This constructor creates an arithmetic exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

ArrayIndexOutOfBoundsException

IndexOutOfBoundsException

This exception class signals that an invalid array index has been used. The definition for the ArrayIndexOutOfBoundsException class follows:

public class java.lang.ArrayIndexOutOfBoundsException
  extends java.lang.IndexOutOfBoundsException {
  // Constructors
  public ArrayIndexOutOfBoundsException();
  public ArrayIndexOutOfBoundsException(int index);
  public ArrayIndexOutOfBoundsException(String s);
}

ArrayIndexOutOfBoundsException

-

ArrayIndexOutOfBoundsException

public ArrayIndexOutOfBoundsException()

This constructor creates a default array-index-out-of-bounds exception with no detail message.

ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException

public ArrayIndexOutOfBoundsException(int index)

This constructor creates an array-index-out-of-bounds exception with the specified invalid index.

index is the invalid index that caused the error.

ArrayIndexOutOfBoundsException

ArrayIndexOutOfBoundsException

public ArrayIndexOutOfBoundsException(String s)

This constructor creates an array-index-out-of-bounds exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

1-2-4

ArrayStoreException

RuntimeException

This exception class signals that an attempt has been made to store the wrong type of object in an array of objects. The definition for the ArrayStoreException class follows:

public class java.lang.ArrayStoreException
  extends java.lang.RuntimeException {
  // Constructors
  public ArrayStoreException();
  public ArrayStoreException(String s);
}

ArrayStoreException

-

ArrayStoreException

public ArrayStoreException()

This constructor creates a default array-store exception with no detail message.

ArrayStoreException

-

ArrayStoreException

public ArrayStoreException(String s)

This constructor creates an array-store exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

ClassCastException

RuntimeException

This exception class signals that an invalid cast has occurred. The definition for the ClassCastException class follows:

public class java.lang.ClassCastException
  extends java.lang.RuntimeException {
  // Constructors
  public ClassCastException();
  public ClassCastException(String s);
}

ClassCastException

ClassCastException

public ClassCastException()

This constructor creates a default class-cast exception with no detail message.

ClassCastException

ClassCastException

public ClassCastException(String s)

This constructor creates a class-cast exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

ClassNotFoundException

Exception

This exception class signals that a class could not be found. The definition for the ClassNotFoundException class follows:

public class java.lang.ClassNotFoundException extends java.lang.Exception {
  // Constructors
  public ClassNotFoundException();
  public ClassNotFoundException(String s);
}

ClassNotFoundException

ClassNotFoundException

public ClassNotFoundException()

This constructor creates a default class-not-found exception with no detail message.

ClassNotFoundException

ClassNotFoundException

public ClassNotFoundException(String s)

This constructor creates a class-not-found exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

CloneNotSupportedException

Exception

This exception class signals that an attempt has been made to clone an object that doesn't support the Cloneable interface. The definition for the CloneNotSupportedException class follows:

public class java.lang.CloneNotSupportedException
  extends java.lang.Exception {
  // Constructors
  public CloneNotSupportedException();
  public CloneNotSupportedException(String s);
}

CloneNotSupportedException

CloneNotSupportedException

public CloneNotSupportedException()

This constructor creates a default clone-not-supported exception with no detail message.

CloneNotSupportedException

CloneNotSupportedException

public CloneNotSupportedException(String s)

This constructor creates a clone-not-supported exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

Exception

Throwable

This throwable class indicates exceptional conditions that a Java program might want to know about. The definition for the Exception class follows:

public class java.lang.Exception extends java.lang.Throwable {
  // Constructors
  public Exception();
  public Exception(String s);
}

Exception

Exception

public Exception()

This constructor creates a default exception with no detail message.

Exception

Exception

public Exception(String s)

This constructor creates an exception with the specified detail message, which contains information specific to the exception.

s is the detail message.

IllegalAccessException

Exception

This exception class signals that the current thread doesn't have access to a class. The definition for the IllegalAccessException class follows:

public class java.lang.IllegalAccessException extends java.lang.Exception {
  // Constructors
  public IllegalAccessException();
  public IllegalAccessException(String s);
}

IllegalAccessException

IllegalAccessException

public IllegalAccessException()

This constructor creates a default illegal-access exception with no detail message.

IllegalAccessException

IllegalAccessException

public IllegalAccessException(String s)

This constructor creates an illegal-access exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

IllegalArgumentException

RuntimeException

This exception class signals that a method has been passed an illegal argument. The definition for the IllegalArgumentException class follows:

public class java.lang.IllegalArgumentException
  extends java.lang.RuntimeException {
  // Constructors
  public IllegalArgumentException();
  public IllegalArgumentException(String s);
}

IllegalArgumentException

IllegalArgumentException

public IllegalArgumentException()

This constructor creates a default illegal-argument exception with no detail message.

IllegalArgumentException

IllegalArgumentException

public IllegalArgumentException(String s)

This constructor creates an illegal-argument exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

IllegalMonitorStateException

RuntimeException

This exception class signals that a thread has attempted to access an object's monitor without owning the monitor. The definition for the IllegalMonitorStateException class follows:

public class java.lang.IllegalMonitorStateException
  extends java.lang.RuntimeException {
  // Constructors
  public IllegalMonitorStateException();
  public IllegalMonitorStateException(String s);
}

IllegalMonitorStateException

IllegalMonitorStateException

public IllegalMonitorStateException()

This constructor creates a default illegal-monitor-state exception with no detail message.

IllegalMonitorStateException

IllegalMonitorStateException

public IllegalMonitorStateException(String s)

This constructor creates an illegal-monitor-state exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

IllegalThreadStateException

IllegalArgumentException

This exception class signals that a thread is not in the proper state for the requested operation. The definition for the IllegalThreadStateException class follows:

public class java.lang.IllegalThreadStateException
  extends java.lang.IllegalArgumentException {
  // Constructors
  public IllegalThreadStateException();
  public IllegalThreadStateException(String s);
}

IllegalThreadStateException

IllegalThreadStateException

public IllegalThreadStateException()

This constructor creates a default illegal-thread-state exception with no detail message.

IllegalThreadStateException

IllegalThreadStateException

public IllegalThreadStateException(String s)

This constructor creates an illegal-thread-state exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

IndexOutOfBoundsException

RuntimeException

This exception class signals that an index of some sort is out of bounds. The definition for the IndexOutOfBoundsException class follows:

public class java.lang.IndexOutOfBoundsException
  extends java.lang.RuntimeException {
  // Constructors
  public IndexOutOfBoundsException();
  public IndexOutOfBoundsException(String s);
}

IndexOutOfBoundsException

IndexOutOfBoundsException

public IndexOutOfBoundsException()

This constructor creates a default index-out-of-bounds exception with no detail message.

IndexOutOfBoundsException

IndexOutOfBoundsException

public IndexOutOfBoundsException(String s)

This constructor creates an index-out-of-bounds exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

InstantiationException

Exception

This exception class signals that an attempt has been made to instantiate an abstract class or an interface. The definition for the InstantiationException class follows:

public class java.lang.InstantiationException extends java.lang.Exception {
  // Constructors
  public InstantiationException();
  public InstantiationException(String s);
}

InstantiationException

InstantiationException

public InstantiationException()

This constructor creates a default instantiation exception with no detail message.

InstantiationException

InstantiationException

public InstantiationException(String s)

This constructor creates an instantiation exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

InterruptedException

Exception

This exception class signals that a thread has been interrupted that already is waiting or sleeping. The definition for the InterruptedException class follows:

public class java.lang.InterruptedException extends java.lang.Exception {
  // Constructors
  public InterruptedException();
  public InterruptedException(String s);
}

InterruptedException

InterruptedException

public InterruptedException()

This constructor creates a default interrupted exception with no detail message.

InterruptedException

InterruptedException

public InterruptedException(String s)

This constructor creates an interrupted exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

NegativeArraySizeException

RuntimeException

This exception class signals that an attempt has been made to create an array with a negative size. The definition for the NegativeArraySizeException class follows:

public class java.lang.NegativeArraySizeException
  extends java.lang.RuntimeException {
  // Constructors
  public NegativeArraySizeException();
  public NegativeArraySizeException(String s);
}

NegativeArraySizeException

NegativeArraySizeException

public NegativeArraySizeException()

This constructor creates a default negative-array-size exception with no detail message.

NegativeArraySizeException

NegativeArraySizeException

public NegativeArraySizeException(String s)

This constructor creates a negative-array-size exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

NullPointerException

RuntimeException

This exception class signals an attempt to access a null pointer as an object. The definition for the NullPointerException class follows:

public class java.lang.NullPointerException extends java.lang.RuntimeException {
  // Constructors
  public NullPointerException();
  public NullPointerException(String s);
}

NullPointerException

NullPointerException

public NullPointerException()

This constructor creates a default null-pointer exception with no detail message.

NullPointerException

NullPointerException

public NullPointerException(String s)

This constructor creates a null-pointer exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

NumberFormatException

IllegalArgumentException

This exception class signals an attempt to convert a string to an invalid number format. The definition for the NumberFormatException class follows:

public class java.lang.NumberFormatException extends
  java.lang.IllegalArgumentException {
  // Constructors
  public NumberFormatException();
  public NumberFormatException(String s);
}

NumberFormatException

NumberFormatException

public NumberFormatException()

This constructor creates a default number-format exception with no detail message.

NumberFormatException

NumberFormatException

public NumberFormatException(String s)

This constructor creates a number-format exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

RuntimeException

Exception

This exception class signals an exceptional condition that can reasonably occur in the Java runtime system. The definition for the RuntimeException class follows:

public class java.lang.RuntimeException extends java.lang.Exception {
  // Constructors
  public RuntimeException();
  public RuntimeException(String s);
}

RuntimeException

RuntimeException

public RuntimeException()

This constructor creates a default runtime exception with no detail message.

RuntimeException

RuntimeException

public RuntimeException(String s)

This constructor creates a runtime exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

SecurityException

RuntimeException

This exception class signals that a security violation has occurred. The definition for the SecurityException class follows:

public class java.lang.SecurityException
  extends java.lang.RuntimeException {
  // Constructors
  public SecurityException();
  public SecurityException(String s);
}

SecurityException

SecurityException

public SecurityException()

This constructor creates a default security exception with no detail message.

SecurityException

SecurityException

public SecurityException(String s)

This constructor creates a security exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

StringIndexOutOfBoundsException

IndexOutOfBoundsException

This exception class signals that an invalid string index has been used. The definition for the StringIndexOutOfBoundsException class follows:

public class java.lang.StringIndexOutOfBoundsException
  extends java.lang.IndexOutOfBoundsException {
  // Constructors
  public StringIndexOutOfBoundsException();
  public StringIndexOutOfBoundsException(int index);
  public StringIndexOutOfBoundsException(String s);
}

StringIndexOutOfBoundsException

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException()

This constructor creates a default string-index-out-of-bounds exception with no detail message.

StringIndexOutOfBoundsException

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException(int index)

This constructor creates a string-index-out-of-bounds exception with the specified invalid index.

index is the invalid index that caused the error.

StringIndexOutOfBoundsException

StringIndexOutOfBoundsException

public StringIndexOutOfBoundsException(String s)

This constructor creates a string-index-out-of-bounds exception with the specified detail message, which contains information specific to this particular exception.

s is the detail message.

AbstractMethodError

IncompatibleClassChangeError

This error class signals an attempt to call an abstract method. The definition for the AbstractMethodError class follows:

public class java.lang.AbstractMethodError
  extends java.lang.IncompatibleClassChangeError {
  // Constructors
  public AbstractMethodError();
  public AbstractMethodError(String s);
}

AbstractMethodError

AbstractMethodError

public AbstractMethodError()

This constructor creates a default abstract-method error with no detail message.

AbstractMethodError

AbstractMethodError

public AbstractMethodError(String s)

This constructor creates an abstract-method error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

ClassFormatError

LinkageError

This error class signals an attempt to read a file in an invalid format. The definition for the ClassFormatError class follows:

public class java.lang.ClassFormatError extends java.lang.LinkageError {
  // Constructors
  public ClassFormatError();
  public ClassFormatError(String s);
}

ClassFormatError

ClassFormatError

public ClassFormatError()

This constructor creates a default class-format error with no detail message.

ClassFormatError

ClassFormatError

public ClassFormatError(String s)

This constructor creates a class-format error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

Error

Throwable

This throwable class indicates a serious problem beyond the scope of what a Java program can fix. The definition for the Error class follows:

public class java.lang.Error extends java.lang.Throwable {
  // Constructors
  public Error();
  public Error(String s);
}

Error

Error

public Error()

This constructor creates a default error with no detail message.

Error

Error

public Error(String s)

This constructor creates an error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

IllegalAccessError

IncompatibleClassChangeError

This error class signals an attempt to access a member variable or call a method without proper access. The definition for the IllegalAccessError class follows:

public class java.lang.IllegalAccessError
  extends java.lang.IncompatibleClassChangeError {
  // Constructors
  public IllegalAccessError();
  public IllegalAccessError(String s);
}

IllegalAccessError

IllegalAccessError

public IllegalAccessError()

This constructor creates a default illegal-access error with no detail message.

IllegalAccessError

IllegalAccessError

public IllegalAccessError(String s)

This constructor creates an illegal-access error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

IncompatibleClassChangeError

LinkageError

This error class signals that an incompatible change has been made to some class definition. The definition for the IncompatibleClassChangeError class follows:

public class java.lang.IncompatibleClassChangeError
  extends java.lang.LinkageError {
  // Constructors
  public IncompatibleClassChangeError();
  public IncompatibleClassChangeError(String s);
}

IncompatibleClassChangeError

IncompatibleClassChangeError

public IncompatibleClassChangeError()

This constructor creates a default incompatible-class-change error with no detail message.

IncompatibleClassChangeError

IncompatibleClassChangeError

public IncompatibleClassChangeError(String s)

This constructor creates an incompatible-class-change error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

InstantiationError

IncompatibleClassChangeError

This error class signals an attempt to instantiate an abstract class or an interface. The definition for the InstantiationError class follows:

public class java.lang.InstantiationError
  extends java.lang.IncompatibleClassChangeError {
  // Constructors
  public InstantiationError();
  public InstantiationError(String s);
}

InstantiationError

InstantiationError

public InstantiationError()

This constructor creates a default instantiation error with no detail message.

InstantiationError

InstantiationError

public InstantiationError(String s)

This constructor creates an instantiation error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

InternalError

VirtualMachineError

This error class signals that some unexpected internal error has occurred. The definition for the InternalError class follows:

public class java.lang.InternalError
  extends java.lang.VirtualMachineError {
  // Constructors
  public InternalError();
  public InternalError(String s);
}

InternalError

InternalError

public InternalError()

This constructor creates a default internal error with no detail message.

InternalError

InternalError

public InternalError(String s)

This constructor creates an internal error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

LinkageError

Error

This error class signals that a class has some dependency on another class, but that the latter class has incompatibly changed after the compilation of the former class. The definition for the LinkageError class follows:

public class java.lang.LinkageError extends java.lang.Error {
  // Constructors
  public LinkageError();
  public LinkageError(String s);
}

LinkageError

LinkageError

public LinkageError()

This constructor creates a default linkage error with no detail message.

LinkageError

LinkageError

public LinkageError(String s)

This constructor creates a linkage error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

NoClassDefFoundError

LinkageError

This error class signals that a class definition could not be found. The definition for the NoClassDefFoundError class follows:

public class java.lang.NoClassDefFoundError
  extends java.lang.LinkageError {
  // Constructors
  public NoClassDefFoundError();
  public NoClassDefFoundError(String s);
}

NoClassDefFoundError

NoClassDefFoundError

public NoClassDefFoundError()

This constructor creates a default no-class-definition-found error with no detail message.

NoClassDefFoundError

NoClassDefFoundError

public NoClassDefFoundError(String s)

This constructor creates a no-class-definition-found error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

NoSuchFieldError

IncompatibleClassChangeError

This error class signals an attempt to access a member variable that doesn't exist. The definition for the NoSuchFieldError class follows:

public class java.lang.NoSuchFieldError
  extends java.lang.IncompatibleClassChangeError {
  // Constructors
  public NoSuchFieldError();
  public NoSuchFieldError(String s);
}

NoSuchFieldError

NoSuchFieldError

public NoSuchFieldError()

This constructor creates a default no-such-field error with no detail message.

NoSuchFieldError

NoSuchFieldError

public NoSuchFieldError(String s)

This constructor creates a no-such-field error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

NoSuchMethodError

IncompatibleClassChangeError

This error class signals an attempt to call a method that doesn't exist. The definition for the NoSuchMethodError class follows:

public class java.lang.NoSuchMethodError
  extends java.lang.IncompatibleClassChangeError {
  // Constructors
  public NoSuchMethodError();
  public NoSuchMethodError(String s);
}

NoSuchMethodError

NoSuchMethodError

public NoSuchMethodError()

This constructor creates a default no-such-method error with no detail message.

NoSuchMethodError

NoSuchMethodError

public NoSuchMethodError(String s)

This constructor creates a no-such-method error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

OutOfMemoryError

VirtualMachineError

This error class signals that the Java runtime system is out of memory. The definition for the OutOfMemoryError class follows:

public class java.lang.OutOfMemoryError
  extends java.lang.VirtualMachineError {
  // Constructors
  public OutOfMemoryError();
  public OutOfMemoryError(String s);
}

OutOfMemoryError

OutOfMemoryError

public OutOfMemoryError()

This constructor creates a default out-of-memory error with no detail message.

OutOfMemoryError

OutOfMemoryError

public OutOfMemoryError(String s)

This constructor creates an out-of-memory error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

StackOverflowError

VirtualMachineError

This error class signals that a stack overflow has occurred. The definition for the StackOverflowError class follows:

public class java.lang.StackOverflowError
  extends java.lang.VirtualMachineError {
  // Constructors
  public StackOverflowError();
  public StackOverflowError(String s);
}

StackOverflowError

StackOverflowError

public StackOverflowError()

This constructor creates a default stack-overflow error with no detail message.

StackOverflowError

StackOverflowError

public StackOverflowError(String s)

This constructor creates a stack-overflow error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

ThreadDeath

Error

This error class signals that a thread is being stopped abnormally via the stop method. The definition for the ThreadDeath class follows:

public class java.lang.ThreadDeath extends java.lang.Error {
  public ThreadDeath();
}

ThreadDeath

ThreadDeath

public ThreadDeath()

This constructor creates a default thread death object.

UnknownError

VirtualMachineError

This error class signals that an unknown but serious error has occurred. The definition for the UnknownError class follows:

public class java.lang.UnknownError extends java.lang.VirtualMachineError {
  // Constructors
  public UnknownError();
  public UnknownError(String s);
}

UnknownError

UnknownError

public UnknownError()

This constructor creates a default unknown error with no detail message.

UnknownError

UnknownError

public UnknownError(String s)

This constructor creates an unknown error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

UnsatisfiedLinkError

LinkageError

This error class signals that a native implementation of a method declared native cannot be found. The definition for the UnsatisfiedLinkError class follows:

public class java.lang.UnsatisfiedLinkError extends java.lang.LinkageError {
  // Constructors
  public UnsatisfiedLinkError();
  public UnsatisfiedLinkError(String s);
}

UnsatisfiedLinkError

UnsatisfiedLinkError

public UnsatisfiedLinkError()

This constructor creates a default unsatisfied-link error with no detail message.

UnsatisfiedLinkError

UnsatisfiedLinkError

public UnsatisfiedLinkError(String s)

This constructor creates an unsatisfied-link error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

VerifyError

LinkageError

This error class signals that a class has failed the runtime verification test. The definition for the VerifyError class follows:

public class java.lang.VerifyError extends java.lang.LinkageError {
  // Constructors
  public VerifyError();
  public VerifyError(String s);
}

VerifyError

VerifyError

public VerifyError()

This constructor creates a default verify error with no detail message.

VerifyError

VerifyError

public VerifyError(String s)

This constructor creates a verify error with the specified detail message, which contains information specific to this particular error.

s is the detail message.

VirtualMachineError

Error

This error class signals that the Java virtual machine is broken or has run out of resources necessary for it to continue operating. The definition for the VirtualMachineError class follows:

public class java.lang.VirtualMachineError extends java.lang.Error {
  // Constructors
  public VirtualMachineError();
  public VirtualMachineError(String s);
}

VirtualMachineError

VirtualMachineError

public VirtualMachineError()

This constructor creates a default virtual-machine error with no detail message.

VirtualMachineError

VirtualMachineError

public VirtualMachineError(String s)

This constructor creates a virtual-machine error with the specified detail message, which contains information specific to this particular error.

s is the detail message.