Generated by
JDiff

java.lang Documentation Differences

This file contains all the changes in documentation in the package java.lang as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class AbstractMethodError

Thrown when an application tries to call an abstract method. Normally this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled. @author unascribed @version 1.13 0915 02/2102/9800 @since JDK1.0

Class ArithmeticException

Thrown when an exceptional arithmetic condition has occurred. For example an integer "divide by zero" throws an instance of this class. @author unascribed @version 1.17 0919 02/2102/9800 @since JDK1.0

Class ArrayIndexOutOfBoundsException

Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array. @author unascribed @version 1.16 0918 02/2102/9800 @since JDK1.0

Class ArrayStoreException

Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects. For example the following code generates an ArrayStoreException:

 Object x[] = new String[3]; x[0] = new Integer(0); 
@author unascribed @version 1.6 098 02/2102/9800 @since JDK1.0

Class Boolean

The Boolean class wraps a value of the primitive type boolean in an object. An object of type Boolean contains a single field whose type is boolean.

In addition this class provides many methods for converting a boolean to a String and a String to a boolean as well as other constants and methods useful when dealing with a boolean. @author Arthur van Hoff @version 1.29 0738 02/2302/9800 @since JDK1.0

Class Boolean, boolean getBoolean(String)

Returns true if and only if the system property named by the argument exists and is equal to the string "true". (Beginning with version 1.0.2 of the JavaTM platform the test of this string is case insensitive.) A system property is accessible through getProperty a method defined by the System class.

If there is no property with the specified name or if the specified name is empty or null then false is returned. @param name the system property name. @return the boolean value of the system property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)

Class Boolean, Boolean valueOf(String)

Returns thea Boolean with booleana value represented by the specified String. A newThe Boolean object is constructed. This Booleanreturned represents the value true if the string argument is not null and is equal ignoring case to the string "true".

Example: Boolean.valueOf("True") returns true.
Example: Boolean.valueOf("yes") returns false. @param s a string. @return the Boolean value represented by the string.


Class Byte

The Byte class is the standard wrapper for byte values. @author Nakul Saraiya @version 1.13 0920 02/2102/9800 @see java.lang.Number @since JDK1.1
Class Byte, int compareTo(Byte)

Compares two Bytes numerically. @param anotherByte the Byte to be compared. @return the value 0 if the argument Byte is equal to this Byte; a value less than 0 if this Byte is numerically less than the Byte argument; and a value greater than 0 if this Byte is numerically greater than the Byte argument (signed comparison). @since JDK11.2
Class Byte, int compareTo(Object)

Compares this Byte to another Object. If the Object is a Byte this function behaves like compareTo(Byte). Otherwise it throws a ClassCastException (as Bytes are comparable only to other Bytes). @param o the Object to be compared. @return the value 0 if the argument is a Byte numerically equal to this Byte; a value less than 0 if the argument is a Byte numerically greater than this Byte; and a value greater than 0 if the argument is a Byte numerically less than this Byte. @exception ClassCastException if the argument is not a Byte. @see java.lang.Comparable @since JDK11.2
Class Byte, Byte decode(String)

Decodes a String into a Byte. The String may representAccepts decimal hexadecimal and octal numbers in the following formats:
 [-] decimal constant [-] 0x hex constant [-] # hex constant [-] 0 octal constant 
The constant following an (optional) negative sign and/or "radix specifier" is parsed as by the Byte.parseByte method with the specified radix (10 8 or 16). This constant must be positive or a NumberFormatException will result. The result is made negative if first character of the specified String is the negative sign. No whitespace characters are permitted in the String
. @param nm the stringString to decode. @return the Byte represented by the specified string. @exception NumberFormatException if the String does not contain a parsable byte. @see java.lang.Byte#parseByte(String int)
Class Byte, byte parseByte(String)

Assuming the specified String represents a byte returns that byte's value. Throws an exception if the String cannot be parsed as a byte. The radix is assumed to be 10. @param s the String containing the byte @return the parsed value of the byte @exception NumberFormatException If the string does not contain a parsable byte.
Class Byte, byte parseByte(String, int)

Assuming the specified String represents a byte returns that byte's value. Throws an exception if the String cannot be parsed as a byte. @param s the String containing the byte @param radix the radix to be used @return the parsed value of the byte @exception NumberFormatException If the String does not contain a parsable byte.
Class Byte, String toString(byte)

Returns a new String object representing the specified Byte. The radix is assumed to be 10. @param b the byte to be converted @return the string representation of the specified byte
Class Byte, Byte valueOf(String)

Assuming the specified String represents a byte returns a new Byte object initialized to that value. Throws an exception if the String cannot be parsed as a byte. The radix is assumed to be 10. @param s the String containing the integer @return the Byte instance representing the parsed byte value @exception NumberFormatException If the String does not contain a parsable byte.
Class Byte, Byte valueOf(String, int)

Assuming the specified String represents a byte returns a new Byte object initialized to that value. Throws an exception if the String cannot be parsed as a byte. @param s the String containing the integer @param radix the radix to be used @return the Byte instance representing the parsed byte value @exception NumberFormatException If the String does not contain a parsable byte.

Class Character

The Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.

In addition this class provides several methods for determining the type of a character and converting characters from uppercase to lowercase and vice versa.

Many of the methods of class Character are defined in terms of a "Unicode attribute table" that specifies a name for every defined Unicode code point. The table also includes other attributes such as a decimal value an uppercase equivalent a lowercase equivalent and/or a titlecase equivalent. The character attribute tables for specific versions of Unicode are available on the World Wide Web in various subdirectories of:

 ftp://ftp.unicode.org/Public/ 

For a more detailed specification of the Character class one that encompasses the exact behavior of methods such as isDigit isLetter isLowerCase and isUpperCase over the full range of Unicode values see Gosling Joy and Steele The Java Language Specification. @author Lee Boynton @author Guy Steele @author Akira Tanaka @version 1.55 9861 02/0902/1600 @since JDK1.0


Class Character.Subset

Instances of this class represent particular subsets of the Unicode character set. The only family of subsets defined in the Character class is {@link Character.UnicodeBlock UnicodeBlock}. Other portions of the Java API may define other subsets for their own purposes. @since JDK11.2

Class Character.UnicodeBlock

A family of character subsets representing the character blocks defined by the Unicode 2.0 specification. Any given character is contained by at most one Unicode block. @since JDK11.2

Class Character, int compareTo(Character)

Compares two Characters numerically. @param anotherCharacter the Character to be compared. @return the value 0 if the argument Character is equal to this Character; a value less than 0 if this Character is numerically less than the Character argument; and a value greater than 0 if this Character is numerically greater than the Character argument (unsigned comparison). Note that this is strictly a numerical comparison; it is not locale-dependent. @since JDK11.2
Class Character, int compareTo(Object)

Compares this Character to another Object. If the Object is a Character this function behaves like compareTo(Character). Otherwise it throws a ClassCastException (as Characters are comparable only to other Characters). @param o the Object to be compared. @return the value 0 if the argument is a Character numerically equal to this Character; a value less than 0 if the argument is a Character numerically greater than this Character; and a value greater than 0 if the argument is a Character numerically less than this Character. @exception ClassCastException if the argument is not a Character. @see java.lang.Comparable @since JDK11.2
Class Character, byte COMBINING_SPACING_MARK

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte CONNECTOR_PUNCTUATION

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte CONTROL

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte CURRENCY_SYMBOL

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte DASH_PUNCTUATION

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte DECIMAL_DIGIT_NUMBER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte ENCLOSING_MARK

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte END_PUNCTUATION

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte FORMAT

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte LETTER_NUMBER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte LINE_SEPARATOR

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte LOWERCASE_LETTER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte MATH_SYMBOL

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte MODIFIER_LETTER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte MODIFIER_SYMBOL

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte NON_SPACING_MARK

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte OTHER_LETTER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte OTHER_NUMBER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte OTHER_PUNCTUATION

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte OTHER_SYMBOL

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte PARAGRAPH_SEPARATOR

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte PRIVATE_USE

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte SPACE_SEPARATOR

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte START_PUNCTUATION

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte SURROGATE

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte TITLECASE_LETTER

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte UNASSIGNED

Public data for enumerated Unicode general category types. @since JDK1.1
Class Character, byte UPPERCASE_LETTER

Public data for enumerated Unicode general category types. @since JDK1.1

Class Class

Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean byte char short int long float and double) and the keyword void are also represented as Class objects.

Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.

The following example uses a Class object to print the class name of an object:

 void printClassName(Object obj) { System.out.println("The class of " + obj + " is " + obj.getClass().getName()); } 
@author unascribed @version 1.100 04107 02/2202/9900 @see java.lang.ClassLoader#defineClass(byte[] int int) @since JDK1.0
Class Class, Class forName(String, boolean, ClassLoader)

Returns the Class object associated with the class or interface with the given string name using the given class loader. Given the fully qualified name for a class or interface (in the same format returned by getName) this method attempts to locate load and link the class or interface. The specified class loader is used to load the class or interface. If the parameter loader is null the class is loaded through the bootstrap class loader. The class is initialized only if the initialize parameter is true and if it has not been initialized earlier.

If name denotes a primitive type or void an attempt will be made to locate a user-defined class in the unnamed package whose name is name. Therefore this method cannot be used to obtain any of the Class objects representing primitive types or void.

If name denotes an array class the component type of the array class is loaded but not initialized.

For example in an instance method the expression:

 Class.forName("Foo") 
is equivalent to:
 Class.forName("Foo" true this.getClass().getClassLoader()) 
Note that this method throws errors related to loading linking or initializing as specified in Sections 12.2 12.3 and 12.4 of The Java Language Specification.

If the loader is null and a security manager is present and the caller's class loader is not null then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the bootstrap class loader. @param name fully qualified name of the desired class @param initialize whether the class must be initialized @param loader class loader from which the class must be loaded @return class object representing the desired class @exception LinkageError if the linkage fails @exception ExceptionInInitializerError if the initialization provoked by this method fails @exception ClassNotFoundException if the class cannot be located by the specified class loader @see java.lang.Class#forName(String) @see java.lang.ClassLoader @since JDK11.2

Class Class, Class[] getClasses()

Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this Class object has no public member classes or interfaces. This method also returns an array of length 0 if this Class object represents a primitive type an array class or void.

For this class and each of its superclasses the following security checks are performed: If there is a security manager the security manager's checkMemberAccess method is called with this and Member.PUBLIC as its arguments where this is this class or the superclass whose members are being determined. If the class is in a package then the security manager's checkPackageAccess method is also called with the package name as its argument. Either of these calls could result in a SecurityException. @return the array of Class objects representing the public members of this class @exception SecurityException if access to the information is denied. @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Class getComponentType()

Returns the Class representing the component type of an array. If this class does not represent an array class this method returns null. @return the Class representing the component type of this class if this class is an array @see java.lang.reflect.Array @since JDK1.1
Class Class, Constructor getConstructor(Class[])

Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object. The parameterTypes parameter is an array of Class objects that identify the constructor's formal parameter types in declared order.

The constructor to reflect is the public constructor of the class represented by this Class object whose formal parameter types match those specified by parameterTypes.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @param parameterTypes the parameter array @return the Method object of the public constructor that matches the specified parameterTypes @exception NoSuchMethodException if a matching method is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Constructor @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Constructor[] getConstructors()

Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object. An array of length 0 is returned if the class has no public constructors or if the class is an array class or if the class reflects a primitive type or void.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @return the array containing Method objects for all the declared public constructors of this class matches the specified parameterTypes @exception SecurityException if access to the information is denied. @see java.lang.reflect.Constructor @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Class[] getDeclaredClasses()

Returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object. This includes public protected default (package) access and private classes and interfaces declared by the class but excludes inherited classes and interfaces. This method returns an array of length 0 if the class declares no classes or interfaces as members or if this Class object represents a primitive type an array class or void.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @return the array of Class objects representing all the declared members of this class @exception SecurityException if access to the information is denied. @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Constructor getDeclaredConstructor(Class[])

Returns a Constructor object that reflects the specified constructor of the class or interface represented by this Class object. The parameterTypes parameter is an array of Class objects that identify the constructor's formal parameter types in declared order.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @param parameterTypes the parameter array @return The Method object for the constructor with the specified parameter list @exception NoSuchMethodException if a matching method is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Constructor @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Constructor[] getDeclaredConstructors()

Returns an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object. These are public protected default (package) access and private constructors. The elements in the array returned are not sorted and are not in any particular order. If the class has a default constructor it is included in the returned array. This method returns an array of length 0 if this Class object represents an interface a primitive type an array class or void.

See The Java Language Specification section 8.2.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @return the array of Method objects representing all the declared constructors of this class @exception SecurityException if access to the information is denied. @see java.lang.reflect.Constructor @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Field getDeclaredField(String)

Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired field. Note that this method will not reflect the length field of an array class.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @param name the name of the field @return the Field object for the specified field in this class @exception NoSuchFieldException if a field with the specified name is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Field @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Field[] getDeclaredFields()

Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. This includes public protected default (package) access and private fields but excludes inherited fields. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no fields or if this Class object represents a primitive type an array class or void.

See The Java Language Specification sections 8.2 and 8.3.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @return the array of Field objects representing all the declared fields of this class @exception SecurityException if access to the information is denied. @see java.lang.reflect.Field @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Method getDeclaredMethod(String, Class[])

Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired method and the parameterTypes parameter is an array of Class objects that identify the method's formal parameter types in declared order. If more than one method with the same parameter types is declared in a class and one of these methods has a return type that is more specific than any of the others that method is returned; otherwise one of the methods is chosen arbitrarily. If the name is "<init>"or "<clinit>" a NoSuchMethodException is raised.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @param name the name of the method @param parameterTypes the parameter array @return the Method object for the method of this class matching the specified name and parameters @exception NoSuchMethodException if a matching method is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Method[] getDeclaredMethods()

Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. This includes public protected default (package) access and private methods but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods or if this Class object represents a primitive type an array class or void. The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types they are all included in the returned array.

See The Java Language Specification section 8.2.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.DECLARED as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException. @return the array of Method objects representing all the declared methods of this class @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Class getDeclaringClass()

If the class or interface represented by this Class object is a member of another class returns the Class object representing the class in which it was declared. This method returns null if this class or interface is not a member of any other class. If this Class object represents an array class a primitive type or void then this method returns null. @return the declaring class for this class @since JDK1.1
Class Class, Field getField(String)

Returns a Field object that reflects the specified public member field of the class or interface represented by this Class object. The name parameter is a String specifying the simple name of the desired field.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.

The field to be reflected is determined by the algorithm that follows. Let C be the class represented by this object:

  1. If C declares a public field with the name specified that is the field to be reflected.
  2. If no field was found in step 1 above this algorithm is applied recursively to each direct superinterface of C. The direct superinterfaces are searched in the order they were declared.
  3. If no field was found in steps 1 and 2 above and C has a superclass S then this algorithm is invoked recursively upon S. If C has no superclass then a NoSuchFieldException is thrown.

See The Java Language Specification sections 8.2 and 8.3. @param name the field name @return the Field object of this class specified by name @exception NoSuchFieldException if a field with the specified name is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Field @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Field[] getFields()

Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields or if it represents an array class a primitive type or void.

Specifically if this Class object represents a class this method returns the public fields of this class and of all its superclasses. If this Class object represents an interface this method returns the fields of this interface and of all its superinterfaces.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.

The implicit length field for array classs is not reflected by this method. User code should use the methods of class Array to manipulate arrays.

See The Java Language Specification sections 8.2 and 8.3. @return the array of Field objects representing the public fields @exception SecurityException if access to the information is denied. @see java.lang.reflect.Field @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Method getMethod(String, Class[])

Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. The name parameter is a String specifying the simple name the desired method. The parameterTypes parameter is an array of Class objects that identify the method's formal parameter types in declared order. If parameterTypes is null it is treated as if it were an empty array.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.

If the name is "<init>"or "<clinit>" a NoSuchMethodException is raised. Otherwise the method to be reflected is determined by the algorithm that follows. Let C be the class represented by this object:

  1. C is searched for any matching methods. If no matching method is found the algorithm of step 1 is invoked recursively on the superclass of C.
  2. If no method was found in step 1 above the superinterfaces of C are searched for a matching method. If any such method is found it is reflected.
To find a matching method in a class C:  If C declares exactly one public method with the specified name and exactly the same formal parameter types that is the method reflected. If more than one such method is found in C and one of these methods has a return type that is more specific than any of the others that method is reflected; otherwise one of the methods is chosen arbitrarily.

See The Java Language Specification sections 8.2 and 8.4. @param name the name of the method @param parameterTypes the list of parameters @return the Method object that matches the specified name and parameterTypes @exception NoSuchMethodException if a matching method is not found or if then name is "<init>"or "<clinit>". @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, Method[] getMethods()

Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object including those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this Class object represents a class or interface that has no public member methods or if this Class object represents an array class primitive type or void.

If there is a security manager this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.

The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types they are all included in the returned array.

See The Java Language Specification sections 8.2 and 8.4. @return the array of Method objects representing the public methods of this class @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1

Class Class, int getModifiers()

Returns the Java language modifiers for this class or interface encoded in an integer. The modifiers consist of the Java Virtual Machine's constants for public protected private final static abstract and interface; they should be decoded using the methods of class Modifier.

If the underlying class is an array class then its public private and protected modifiers are the same as those of its component type. If this Class represents a primitive type or void its public modifier is always true and its protected and private modifers are always false. If this object represents an array class a primitive type or void then its final modifier is always true and its interface modifer is always false. The values of its other modifiers are not determined by this specification.

The modifier encodings are defined in The Java Virtual Machine Specification table 4.1. @return the int representing the modifiers for this class @see java.lang.reflect.Modifier @since JDK1.1

Class Class, ProtectionDomain getProtectionDomain()

Returns the ProtectionDomain of this class. If there is a security manager installed this method first calls the security manager's checkPermission method with a RuntimePermission("getProtectionDomain") permission to ensure it's ok to get the ProtectionDomain. @return the ProtectionDomain of this class @throws SecurityException if a security manager exists and its checkPermission method doesn't allow geting the ProtectionDomain. @see java.security.ProtectionDomain @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK11.2
Class Class, boolean isAssignableFrom(Class)

Determines if the class or interface represented by this Class object is either the same as or is a superclass or superinterface of the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false. If this Class object represents a primitive type this method returns true if the specified Class parameter is exactly this Class object; otherwise it returns false.

Specifically this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class object via an identity conversion or via a widening reference conversion. See The Java Language Specification sections 5.1.1 and 5.1.4 for details. @param cls the Class object to be checked @return the boolean value indicating whether objects of the type cls can be assigned to objects of this class @exception NullPointerException if the specified Class parameter is null. @since JDK1.1

Class Class, boolean isInstance(Object)

Determines if the specified Object is assignment-compatible with the object represented by this Class. This method is the dynamic equivalent of the Java language instanceof operator. The method returns true if the specified Object argument is non-null and can be cast to the reference type represented by this Class object without raising a ClassCastException. It returns false otherwise.

Specifically if this Class object represents a declared class this method returns true if the specified Object argument is an instance of the represented class (or of any of its subclasses); it returns false otherwise. If this Class object represents an array class this method returns true if the specified Object argument can be converted to an object of the array class by an identity conversion or by a widening reference conversion; it returns false otherwise. If this Class object represents an interface this method returns true if the class or any superclass of the specified Object argument implements this interface; it returns false otherwise. If this Class object represents a primitive type this method returns false. @param obj the object to check @return true if obj is an instance of this class @since JDK1.1

Class Class, boolean isPrimitive()

Determines if the specified Class object represents a primitive type.

There are nine predefined Class objects to represent the eight primitive types and void. These are created by the Java Virtual Machine and have the same names as the primitive types that they represent namely boolean byte char short int long float and double.

These objects may only be accessed via the following public static final variables and are the only Class objects for which this method returns true. @return true if and only if this class represents a primitive type @see java.lang.Boolean#TYPE @see java.lang.Character#TYPE @see java.lang.Byte#TYPE @see java.lang.Short#TYPE @see java.lang.Integer#TYPE @see java.lang.Long#TYPE @see java.lang.Float#TYPE @see java.lang.Double#TYPE @see java.lang.Void#TYPE @since JDK1.1


Class ClassCastException

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example the following code generates a ClassCastException:

 Object x = new Integer(0); System.out.println((String)x); 
@author unascribed @version 1.15 0917 02/2102/9800 @since JDK1.0

Class ClassCircularityError

Thrown when a circularity has been detected while initializing a class. @author unascribed @version 1.10 0912 02/2102/9800 @since JDK1.0

Class ClassFormatError

Thrown when the Java Virtual Machine attempts to read a class file and determines that the file is malformed or otherwise cannot be interpreted as a class file. @author unascribed @version 1.15 0917 02/2102/9800 @since JDK1.0

Class ClassLoader

The class ClassLoader is an abstract class. A class loader is an object that is responsible for loading classes. Given the name of a class it should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system.

Every Class object contains a reference to the ClassLoader that defined it.

Class objects for array classes are not created by class loaders but are created automatically as required by the Java runtime. The class loader for an array class as returned by Class#getClassLoader() is the same as the class loader for its element type; if the element type is a primitive type then the array class has no class loader.

Applications implement subclasses of ClassLoader in order to extend the manner in which the Java virtual machine dynamically loads classes.

Class loaders may typically be used by security managers to indicate security domains.

The ClassLoader class uses a delegation model to search for classes and resources. Each instance of ClassLoader has an associated parent class loader. When called upon to find a class or resource a ClassLoader instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader called the bootstrap class loader does not itself have a parent but may serve as the parent of a ClassLoader instance.

Normally the Java virtual machine loads classes from the local file system in a platform-dependent manner. For example on UNIX systems the virtual machine loads classes from the directory defined by the CLASSPATH environment variable.

However some classes may not originate from a file; they may originate from other sources such as the network or they could be constructed by an application. The method defineClass converts an array of bytes into an instance of class Class. Instances of this newly defined class can be created using the newInstance method in class Class.

The methods and constructors of objects created by a class loader may reference other classes. To determine the class(es) referred to the Java virtual machine calls the loadClass method of the class loader that originally created the class.

For example an application could create a network class loader to download class files from a server. Sample code might look like:

 ClassLoader loader = new NetworkClassLoader(host  port); Object main = loader.loadClass("Main" true).newInstance();  . . . 

The network class loader subclass must define the methods findClass and loadClassData to load a class from the network. Once it has downloaded the bytes that make up the class it should use the method defineClass to create a class instance. A sample implementation is:


 class NetworkClassLoader extends ClassLoader { String host; int port; public Class findClass(String name) { byte[] b = loadClassData(name); return defineClass(name b 0 b.length); } private byte[] loadClassData(String name) { // load the class data from the connection  . . . } } 

@version 1.129 05142 02/1917/00 @see java.lang.Class @see java.lang.Class#newInstance() @see java.lang.ClassLoader#defineClass(byte[] int int) @see java.lang.ClassLoader#loadClass(java.lang.String boolean) @see java.lang.ClassLoader#resolveClass(java.lang.Class) @since JDK1.0
Class ClassLoader, constructor ClassLoader(ClassLoader)

Creates a new class loader using the specified parent class loader for delegation.

If there is a security manager its checkCreateClassLoader method is called. This may result in a security exception. @throws SecurityException if a security manager exists and its checkCreateClassLoader method doesn't allow creation of a new class loader. @param parent the parent class loader @see java.lang.SecurityException @see java.lang.SecurityManager#checkCreateClassLoader() @since JDK11.2

Class ClassLoader, Class defineClass(String, byte[], int, int, ProtectionDomain)

Converts an array of bytes into an instance of class Class with an optional ProtectionDomain. If the domain is null then a default domain will be assigned to the class as specified in the documentation for byte[ int int)}. Before the class can be used it must be resolved.

The first class defined in a package determines the exact set of certificates that all subsequent classes defined in that package must contain. The set of certificates for a class is obtained from the CodeSource within the ProtectionDomain of the class. Any classes added to that package must contain the same set of certificates or a SecurityException will be thrown. Note that if the name argument is null this check is not performed. You should always pass in the name of the class you are defining as well as the bytes. This ensures that the class you are defining is indeed the class you think it is.

The specified class name cannot begin with "java." since all classes in the java.* packages can only be defined by the bootstrap class loader. @exception ClassFormatError if the data did not contain a valid class @exception IndexOutOfBoundsException if either off or len is negative or if off+len is greater than b.length. @exception SecurityException if an attempt is made to add this class to a package that contains classes that were signed by a different set of certificates thenthan this class or if the class name begins with "java.". @param name the name of the class @param b the class bytes @param off the start offset of the class bytes @param len the length of the class bytes @param protectionDomain the ProtectionDomain of the class @return the Class object created from the data and optional ProtectionDomain.

Class ClassLoader, Package definePackage(String, String, String, String, String, String, String, URL)

Defines a package by name in this ClassLoader. This allows class loaders to define the packages for their classes. Packages must be created before the class is defined and package names must be unique within a class loader and cannot be redefined or changed once created. @param name the package name @param specTitle the specification title @param specVersion the specification version @param specVendor the specification vendor @param implTitle the implementation title @param implVersion the implementation version @param implVendor the implementation vendor @param sealBase If not null then this package is sealed with respect to the given code source URL. Otherwise the package is not sealed. @return the newly defined Package object @exception IllegalArgumentException if package name duplicates an existing package either in this class loader or one of its ancestors @since JDK11.2
Class ClassLoader, Class findClass(String)

Finds the specified class. This method should be overridden by class loader implementations that follow the new delegation model for loading classes and will be called by the loadClass method after checking the parent class loader for the requested class. The default implementation throws ClassNotFoundException. @param name the name of the class @return the resulting Class object @exception ClassNotFoundException if the class could not be found @since JDK11.2
Class ClassLoader, String findLibrary(String)

Returns the absolute path name of a native library. The VM invokes this method to locate the native libraries that belong to classes loaded with this class loader. If this method returns null the VM searches the library along the path specified as the java.library.path property. @param libname the library name @return the absolute path of the native library @see java.lang.System#loadLibrary(java.lang.String) @see java.lang.System#mapLibraryName(java.lang.String) @since JDK11.2
Class ClassLoader, URL findResource(String)

Finds the resource with the given name. Class loader implementations should override this method to specify where to find resources. @param name the resource name @return a URL for reading the resource or null if the resource could not be found @since JDK11.2
Class ClassLoader, Enumeration findResources(String)

Returns an Enumeration of URLs representing all the resources with the given name. Class loader implementations should override this method to specify where to load resources from. @param name the resource name @return an Enumeration of URLs for the resources @throws IOException if I/O errors occur @since JDK11.2
Class ClassLoader, Class findSystemClass(String)

Finds a class with the specified name loading it if necessary.

Prior to JDK1.the Java 2 SDK this method loads a class from the local file system in a platform-dependent manner and returns a class object that has no associated class loader.

Since JDK1the Java 2 SDK v1.2 this method loads the class through the system class loader(see Clas objects returned might have ClassLoaders associated with them. Subclasses of ClassLoader need not usually call this method because most class loaders need to override just @separa #ClassLoader(ClassLoader) @see #getParent() @param name the name of the class that is to be found @return athe systemClass class withobject for the givenspecified name @exception ClassNotFoundException if the class could not be found @see #ClassLoader(ClassLoader) @see #getParent()

Class ClassLoader, Package getPackage(String)

Returns a Package that has been defined by this class loader or any of its ancestors. @param name the package name @return the Package corresponding to the given name or null if not found @since JDK11.2
Class ClassLoader, Package[] getPackages()

Returns all of the Packages defined by this class loader and its ancestors. @return the array of Package objects defined by this ClassLoader @since JDK11.2
Class ClassLoader, ClassLoader getParent()

Returns the parent class loader for delegation. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class loader's parent is the bootstrap class loader.

If a security manager is present and the caller's class loader is not null and is not an ancestor of this class loader then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the parent class loader. If not a SecurityException will be thrown. @return the parent ClassLoader @throws SecurityException if a security manager exists and its checkPermission method doesn't allow access to this class loader's parent class loader. @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK11.2

Class ClassLoader, Enumeration getResources(String)

Finds all the resources with the given name. A resource is some data (images audio text etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a "/"-separated path name that identifies the resource.

The search order is described in the documentation for @para name resource name @return an enumeration of URL to the resource. If no resources could be found the enumeration will be empty. Resources that the doesn't have access to will not be in the enumeration. @throws IOException if I/O errors occur @since JDK11.2 @see #getResource @see #findResources

Class ClassLoader, ClassLoader getSystemClassLoader()

Returns the system class loader for delegation. This is the default delegation parent for new ClassLoader instances and is typically the class loader used to start the application.

If a security manager is present and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the system class loader then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the system class loader. If not a SecurityException will be thrown. @return the system ClassLoader for delegation or null if none @throws SecurityException if a security manager exists and its checkPermission method doesn't allow access to the system class loader. @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK11.2

Class ClassLoader, URL getSystemResource(String)

Find a resource of the specified name from the search path used to load classes.

In JDK1.1 the search path used is that of the virtual machine's built-in class loader.

Since JDK1the Java 2 SDK v1.2 this method locates the resource through the system class loader (see @para name the resource name @return a URL for reading the resource or null if the resource could not be found @since JDK1.1

Class ClassLoader, Enumeration getSystemResources(String)

Finds all resources of the specified name from the search path used to load classes. The resources thus found are returned as an Enumeration of URL objects.

The search order is described in the documentation for #getSystemResource(String)

@param name the resource name @return an enumeration of resource URLs @throws IOException if I/O errors occur @since JDK11.2

Class ClassLoader, Class loadClass(String, boolean)

Loads the class with the specified name. The default implementation of this method searches for classes in the following order:

  1. Call #findLoadedClass(String) to check if the class has already been loaded.

  2. Call the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used instead.

  3. Call the #findClass(String) method to find the class.

If the class was found using the above steps and the resolve flag is true this method will then call the #resolveClass(Class) method on the resulting class object.

From JDK1the Java 2 SDK v1.2 subclasses of ClassLoader are encouraged to override #findClass(String) rather than this method.

@param name the name of the class @param resolve if true then resolve the class @return the resulting Class object @exception ClassNotFoundException if the class could not be found


Class ClassNotFoundException

Thrown when an application tries to load in a class through its string name using:

but no definition for the class with the specifed name could be found. @author unascribed @version 1.8 0513 02/0402/9800 @see java.lang.Class#forName(java.lang.String) @see java.lang.ClassLoader#findSystemClass(java.lang.String) @see java.lang.ClassLoader#loadClass(java.lang.String boolean) @since JDK1.0

Class ClassNotFoundException, constructor ClassNotFoundException(String, Throwable)

Constructs a ClassNotFoundException with the specified detail message and optional exception that was raised while loading the class. @param s the detail message @param ex the exception that was raised while loading the class @since JDK11.2
Class ClassNotFoundException, Throwable getException()

Returns the exception that was raised if an error occurred while attempting to load the class. Otherwise returns null. @return the Exception that was raised while loading a class @since JDK11.2

Class CloneNotSupportedException

Thrown to indicate that the clone method in class Object has been called to clone an object but that the object's class does not implement the Cloneable interface.

Applications that override the clone method can also throw this exception to indicate that an object could not or should not be cloned. @author unascribed @version 1.6 098 02/2102/9800 @see java.lang.Cloneable @see java.lang.Object#clone() @since JDK1.0


Class Cloneable

A class implements the Cloneable interface to indicate to the java.lang.Object#clone() method that it is legal for that method to make a field-for-field copy of instances of that class.

Attempts to clone instances that do not implement the Cloneable interface result in the exception CloneNotSupportedException being thrown.

The interface Cloneable declares no methods. @author unascribed @version 1.8 0910 02/2102/9800 @see java.lang.CloneNotSupportedException @since JDK1.0


Class Comparable

This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering and the class's compareTo method is referred to as its natural comparison method.

Lists (and arrays) of objects that implement this interface can be sorted automatically by Collections.sort (and Arrays.sort). Objects that implement this interface can be used as keys in a sorted map or elements in a sorted set without the need to specify a comparator.

A class's natural ordering is said to be consistent with equals if and only if (e1.compareTo((Object)e2)==0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 of class C.

It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular such a sorted set (or sorted map) violates the general contract for set (or map) which is defined in terms of the equals operation.

For example if one adds two keys a and b such that (a.equals((Object)b) && a.compareTo((Object)b) = 0) to a sorted set that does not use an explicit comparator the second add operation returns false (and the size of the sorted set does not increase) because a and b are equivalent from the sorted set's perspective.

Virtually all Java core classes that implement comparable have natural orderings that are consistent with equals. One exception is java.math.BigDecimal whose natural ordering equates BigDecimals with equal values and different precisions (such as 4.0 and 4.00).

For the mathematically inclined the relation that defines the natural ordering on a given class C is:

 {(x y) such that x.compareTo((Object)y) <= 0}. 
The quotient for this total order is:
 {(x y) such that x.compareTo((Object)y) == 0}. 
It follows immediately from the contract for compareTo that the quotient is an equivalence relation on C and that the natural ordering is a total order on C. When we say that a class's natural ordering is consistent with equals we mean that the quotient for the natural ordering is the equivalence relation defined by the class's equals(Object) method:
 {(x y) such that x.equals((Object)y)}. 
@author Josh Bloch @version 1.9 0913 02/3002/9800 @see java.util.Comparator @see java.util.Collections#sort(java.util.List) @see java.util.Arrays#sort(Object[]) @see java.util.SortedSet @see java.util.SortedMap @see java.util.TreeSet @see java.util.TreeMap @since JDK11.2

Class Compiler

The Compiler class is provided to support Java-to-native-code compilers and related services. By design the Compiler class does nothing; it serves as a placeholder for a JIT compiler implementation.

When the Java Virtual Machine first starts it determines if the system property java.compiler exists. (System properties are accessible through getProperty and a method defined by the System class.) If so it is assumed to be the name of a library (with a platform-dependent exact location and type); the loadLibrary method in class System is called to load that library. If this loading succeeds the function named java_lang_Compiler_start() in that library is called.

If no compiler is available these methods do nothing. @author Frank Yellin @version 1.12 0615 02/2902/9800 @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.System#loadLibrary(java.lang.String) @since JDK1.0


Class Double

The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.

In addition this class provides several methods for converting a double to a String and a String to a double as well as other constants and methods useful when dealing with a double. @author Lee Boynton @author Arthur van Hoff @version 1.54 0963 02/1102/9800 @since JDK1.0

Class Double, int compareTo(Double)

Compares two Doubles numerically. There are two ways in which comparisons performed by this method differ from those performed by the Java language numerical comparison operators (< <= == >= >) when applied to primitive doubles: This ensures that Double.compareTo(Object) (which inherits its behavior from this method) obeys the general contract for Comparable.compareTo and that the natural order on Doubles is total. @param anotherDouble the Double to be compared. @return the value 0 if anotherDouble is numerically equal to this Double; a value less than 0 if this Double is numerically less than anotherDouble; and a value greater than 0 if this Double is numerically greater than anotherDouble. @since JDK11.2 @see Comparable#compareTo(Object)
Class Double, int compareTo(Object)

Compares this Double to another Object. If the Object is a Double this function behaves like compareTo(Double). Otherwise it throws a ClassCastException (as Doubles are comparable only to other Doubles). @param o the Object to be compared. @return the value 0 if the argument is a Double numerically equal to this Double; a value less than 0 if the argument is a Double numerically greater than this Double; and a value greater than 0 if the argument is a Double numerically less than this Double. @exception ClassCastException if the argument is not a Double. @see java.lang.Comparable @since JDK11.2
Class Double, int hashCode()

Returns a hashcode for this Double object. The result is the exclusive OR of the two halves of the long integer bit representation exactly as produced by the method #doubleToLongBits(double) of the primitive double value represented by this Double object. That is the hashcode is the value of the expression:
 (int)(v^(v>>>32)) 
where v is defined by:
 long v = Double.doubleToLongBits(this.longValuedoubleValue()); 
@return a hash code value for this object.
Class Double, double longBitsToDouble(long)

Returns the double-float corresponding to a given bit represention. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double precision" bit layout. That floating-point value is returned as the result.

If the argument is 0x7ff0000000000000L the result is positive infinity.

If the argument is 0xfff0000000000000L the result is negative infinity.

If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL the result is NaN. All IEEE 754 NaN values of type double are in effect lumped together by the Java programming language into a single value called NaN. Distinct values of NaN are only accessible by use of the Double.doubleToRawLongBits method.

In all other cases let s e and m be three values that can be computed from the argument:

 int s = ((bits >> 63) == 0) 1 : -1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) (bits & 0xfffffffffffffL) < 1 : (bits & 0xfffffffffffffL) | 0x10000000000000L; 
Then the floating-point result equals the value of the mathematical expression s·m·2e-1075. @param bits any long integer. @return the double floating-point value with the same bit pattern.
Class Double, double parseDouble(String)

Returns a new double initialized to the value represented by the specified String as performed by the valueOf method of class Double. @param s the string to be parsed. @return the double value represented by the string argument. @exception NumberFormatException if the string does not contain a parsable double. @see java.lang.Double#valueOf(String) @since JDK11.2
Class Double, String toString(double)

Creates a string representation of the double argument. All characters mentioned below are ASCII characters.

How many digits must be printed for the fractional part of m or a There must be at least one digit to represent the fractional part and beyond that as many but only as many more digits as are needed to uniquely distinguish the argument value from adjacent values of type double. That is suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument d. Then d must be the double value nearest to x; or if two double values are equally close to x then d must be one of them and the least significant bit of the significand of d must be 0. @param d the double to be converted. @return a string representation of the argument.


Class Error

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error though a "normal" condition is also a subclass of Error because most applications should not try to catch it.

A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught since these errors are abnormal conditions that should never occur. @author Frank Yellin @version 1.10 0912 02/2102/9800 @see java.lang.ThreadDeath @since JDK1.0


Class Exception

The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch. @author Frank Yellin @version 1.25 0927 02/2102/9800 @see java.lang.Error @since JDK1.0

Class ExceptionInInitializerError

Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable. @author Frank Yellin @version 1.9 0811 02/2502/9800 @since JDK1.1

Class Float

The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is float.

In addition this class provides several methods for converting a float to a String and a String to a float as well as other constants and methods useful when dealing with a float. @author Lee Boynton @author Arthur van Hoff @version 1.48 0760 02/2302/9800 @since JDK1.0

Class Float, int compareTo(Float)

Compares two Floats numerically. There are two ways in which comparisons performed by this method differ from those performed by the Java language numerical comparison operators (< <= == >= >) when applied to primitive floats: This ensures that Float.compareTo(Object) (which inherits its behavior from this method) obeys the general contract for Comparable.compareTo and that the natural order on Floats is total. @param anotherFloat the Float to be compared. @return the value 0 if anotherFloat is numerically equal to this Float; a value less than 0 if this Float is numerically less than anotherFloat; and a value greater than 0 if this Float is numerically greater than anotherFloat. @since JDK11.2 @see Comparable#compareTo(Object)
Class Float, int compareTo(Object)

Compares this Float to another Object. If the Object is a Float this function behaves like compareTo(Float). Otherwise it throws a ClassCastException (as Floats are comparable only to other Floats). @param o the Object to be compared. @return the value 0 if the argument is a Float numerically equal to this Float; a value less than 0 if the argument is a Float numerically greater than this Float; and a value greater than 0 if the argument is a Float numerically less than this Float. @exception ClassCastException if the argument is not a Float. @see java.lang.Comparable @since JDK11.2
Class Float, boolean equals(Object)

Compares this object against some other object. The result is true if and only if the argument is not null and is a Float object that represents a float that has the identical bit pattern to the bit pattern of the float represented by this object. For this purpose two float values are considered to be the same if and only if the method #floatToIntBits(float) returns the same int value when applied to each.

Note that in most cases for two instances of class Float f1 and f2 the value of f1.equals(f2) is true if and only if

 f1.floatValue() == f2.floatValue() 

also has the value true. However there are two exceptions:

This definition allows hashtables to operate properly. @param obj the object to be compared @return true if the objects are the same; false otherwise. @see java.lang.Float#floatToIntBits(float)
Class Float, float intBitsToFloat(int)

Returns the single-float corresponding to a given bit represention. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single precision" bit layout.

If the argument is 0x7f800000 the result is positive infinity.

If the argument is 0xff800000 the result is negative infinity.

If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff the result is NaN. All IEEE 754 NaN values of type float are in effect lumped together by the Java programming language into a single float value called NaN. Distinct values of NaN are only accessible by use of the Float.floatToRawIntBits method.

In all other cases let s e and m be three values that can be computed from the argument:

 int s = ((bits >> 31) == 0) 1 : -1; int e = ((bits >> 23) & 0xff); int m = (e == 0) (bits & 0x7fffff) < 1 : (bits & 0x7fffff) | 0x800000; 
Then the floating-point result equals the value of the mathematical expression s·m·2e-150. @param bits an integer. @return the single-format floating-point value with the same bit pattern.
Class Float, float parseFloat(String)

Returns a new float initialized to the value represented by the specified String as performed by the valueOf method of class Double. @param s the string to be parsed. @return the float value represented by the string argument. @exception NumberFormatException if the string does not contain a parsable float. @see java.lang.Double#valueOf(String) @since JDK11.2

Class IllegalAccessError

Thrown if an application attempts to access or modify a field or to call a method that it does not have access to.

Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.11 0913 02/2102/9800 @since JDK1.0


Class IllegalAccessException

Thrown when an application tries to load in a class through its string name using: The forName method in class Class. The findSystemClass method in class ClassLoader. The loadClass method in class ClassLoader. but the currently executing method does not have access to the definition of the specified class because the class is not public and in another package.

An instance of this class can also be thrown when an application tries to create an instance of a class using the newInstance method in class Class but the current method does not have access to the appropriate zero-argument constructor. @author unascribed @version 1.6 099 02/2102/9800 @see java.lang.Class#forName(java.lang.String) @see java.lang.Class#newInstance() @see java.lang.ClassLoader#findSystemClass(java.lang.String) @see java.lang.ClassLoader#loadClass(java.lang.String boolean) @since JDK1.0


Class IllegalArgumentException

Thrown to indicate that a method has been passed an illegal or inappropriate argument. @author unascribed @version 1.15 0917 02/2102/9800 @see java.lang.Thread#setPriority(int) @since JDK1.0

Class IllegalMonitorStateException

Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor. @author unascribed @version 1.7 099 02/2102/9800 @see java.lang.Object#notify() @see java.lang.Object#notifyAll() @see java.lang.Object#wait() @see java.lang.Object#wait(long) @see java.lang.Object#wait(long int) @since JDK1.0

Class IllegalStateException

Signals that a method has been invoked at an illegal or inappropriate time. In other words the Java environment or Java application is not in an appropriate state for the requested operation. @author Jonni Kanerva @version 1.7 099 02/2102/9800 @since JDK1.1

Class IllegalThreadStateException

Thrown to indicate that a thread is not in an appropriate state for the requested operation. See for example the suspend and resume methods in class Thread. @author unascribed @version 1.16 0918 02/2102/9800 @see java.lang.Thread#resume() @see java.lang.Thread#suspend() @since JDK1.0

Class IncompatibleClassChangeError

Thrown when an incompatible class change has occurred to some class definition. The definition of some class on which the currently executing method depends has since changed. @author unascribed @version 1.13 0915 02/2102/9800 @since JDK1.0

Class IndexOutOfBoundsException

Thrown to indicate that an index of some sort (such as to an array to a string or to a vector) is out of range.

Applications can subclass this class to indicate similar exceptions. @author Frank Yellin @version 1.6 098 02/2102/9800 @since JDK1.0


Class InheritableThreadLocal

This class extends ThreadLocal to provide inheritance of values from parent Thread to child Thread: when a child thread is created the child receives initial values for all InheritableThreadLocals for which the parent has values. Normally the child's values will be identical to the parent's; however the child's value can be made an arbitrary function of the parent's by overriding the childValue method in this class.

InheritableThreadLocal variables are used in preference to ordinary ThreadLocal variables when the per-thread-attribute being maintained in the variable (e.g. User ID Transaction ID) must be automatically transmitted to any child threads that are created. @author Josh Bloch @version 1.2 0610 02/2902/9800 @see ThreadLocal @since JDK11.2

Class InheritableThreadLocal, Object childValue(Object)

Computes the child's initial value for this InheritableThreadLocal as a function of the parent's value at the time the child Thread is created. This method is called from within the parent thread before the child is started.

This method merely returns its input argument and should be overridden if a different behavior is desired. @param parentValue the parent thread's value @return the child thread's initial value


Class InstantiationError

Thrown when an application tries to use the Java new construct to instantiate an abstract class or an interface.

Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.7 099 02/2102/9800 @since JDK1.0


Class InstantiationException

Thrown when an application tries to create an instance of a class using the newInstance method in class Class but the specified class object cannot be instantiated because it is an interface or is an abstract class. @author unascribed @version 1.12 0914 02/2102/9800 @see java.lang.Class#newInstance() @since JDK1.0

Class Integer

The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.

In addition this class provides several methods for converting an int to a String and a String to an int as well as other constants and methods useful when dealing with an int. @author Lee Boynton @author Arthur van Hoff @version 1.54 0862 02/2602/9800 @since JDK1.0

Class Integer, int compareTo(Integer)

Compares two Integers numerically. @param anotherInteger the Integer to be compared. @return the value 0 if the argument Integer is equal to this Integer; a value less than 0 if this Integer is numerically less than the Integer argument; and a value greater than 0 if this Integer is numerically greater than the Integer argument (signed comparison). @since JDK11.2
Class Integer, int compareTo(Object)

Compares this Integer to another Object. If the Object is a Integer this function behaves like compareTo(Integer). Otherwise it throws a ClassCastException (as Integers are comparable only to other Integers). @param o the Object to be compared. @return the value 0 if the argument is a Integer numerically equal to this Integer; a value less than 0 if the argument is a Integer numerically greater than this Integer; and a value greater than 0 if the argument is a Integer numerically less than this Integer. @exception ClassCastException if the argument is not an Integer. @see java.lang.Comparable @since JDK11.2
Class Integer, Integer decode(String)

Decodes a String into an Integer. Accepts decimal hexadecimal and octal numbers in the following formats:
 [-] decimal constant [-] 0x hex constant [-] # hex constant [-] 0 octal constant 
The constant following an (optional) negative sign and/or "radix specifier" is parsed as by the Integer.parseInt method with the specified radix (10 8 or 16). This constant must be positive or a NumberFormatException will result. The result is made negative if first character of the specified String is the negative sign. No whitespace characters are permitted in the String. @param nm the String to decode. @return the Integer represented by the specified string. @exception NumberFormatException if the String does not contain a parsable integer. @see java.lang.Integer#parseInt(String int)
Class Integer, Integer getInteger(String)

Determines the integer value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned. Details of possible numeric formats can be found with the definition of getProperty.

If there is no property with the specified name if the specified name is empty or null or if the property does not have the correct numeric format then null is returned. In other words this method returns an Integer object equal to the value of:

 getInteger(nm null) 
@param nm property name. @return the Integer value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Class Integer, Integer getInteger(String, Integer)

Returns the integer value of the system property with the specified name. The first argument is treated as the name of a system property. System properties are accessible through getProperty a method defined by the System class. The string value of this property is then interpreted as an integer value as per the Integer.decode method and an Integer object representing this value is returned.

The second argument is the default value. IfThe default value is returned if there is no property of the specified name or if the property does not have the correct numeric format thenor if the second argumentspecified name is returnedempty or null. @param nm property name. @param val default value. @return the Integer value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.Integer#decode

Class Integer, Integer getInteger(String, int)

Determines the integer value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through getProperty a method defined by the System class. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned. Details of possible numeric formats can be found with the definition of getProperty.

IfThe second argument is the default value. An Integer object that represents the value of the second argument is returned if there is no property withof the specified name or if the property does not have the correct numeric format then an Integer object thator representsif the value ofspecified the second argument is returnedname is empty or null.

In other words this method returns an Integer object equal to the value of:

 getInteger(nm new Integer(val)) 
but in practice it may be implemented in a manner such as:
 Integer result = getInteger(nm null); return (result == null) new Integer(val) : result; 
to avoid the unnecessary allocation of an Integer object when the default value is not needed. @param nm property name. @param val default value. @return the Integer value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)

Class InternalError

Thrown to indicate some unexpected internal error has occurred in the Java Virtual Machine. @author unascribed @version 1.16 0918 02/2102/9800 @since JDK1.0

Class InterruptedException

Thrown when a thread is waiting sleeping or otherwise paused for a long time and another thread interrupts it using the interrupt method in class Thread. @author Frank Yellin @version 1.10 0912 02/2102/9800 @see java.lang.Object#wait() @see java.lang.Object#wait(long) @see java.lang.Object#wait(long int) @see java.lang.Thread#sleep(long) @see java.lang.Thread#interrupt() @see java.lang.Thread#interrupted() @since JDK1.0

Class LinkageError

Subclasses of LinkageError indicate that a class has some dependency on another class; however the latter class has incompatibly changed after the compilation of the former class. @author Frank Yellin @version 1.8 0910 02/2102/9800 @since JDK1.0

Class Long

The Long class wraps a value of the primitive type long in an object. An object of type Long contains a single field whose type is long.

In addition this class provides several methods for converting a long to a String and a String to a long as well as other constants and methods useful when dealing with a long. @author Lee Boynton @author Arthur van Hoff @version 1.42 0852 02/2602/9800 @since JDK1.0

Class Long, int compareTo(Long)

Compares two Longs numerically. @param anotherLong the Long to be compared. @return the value 0 if the argument Long is equal to this Long; a value less than 0 if this Long is numerically less than the Long argument; and a value greater than 0 if this Long is numerically greater than the Long argument (signed comparison). @since JDK11.2
Class Long, int compareTo(Object)

Compares this Long to another Object. If the Object is a Long this function behaves like compareTo(Long). Otherwise it throws a ClassCastException (as Longs are comparable only to other Longs). @param o the Object to be compared. @return the value 0 if the argument is a Long numerically equal to this Long; a value less than 0 if the argument is a Long numerically greater than this Long; and a value greater than 0 if the argument is a Long numerically less than this Long. @exception ClassCastException if the argument is not a Long. @see java.lang.Comparable @since JDK11.2
Class Long, Long decode(String)

Decodes a String into a Long. Accepts decimal hexadecimal and octal numbers in the following formats:
 [-] decimal constant [-] 0x hex constant [-] # hex constant [-] 0 octal constant 
The constant following an (optional) negative sign and/or "radix specifier" is parsed as by the Long.parseLong method with the specified radix (10 8 or 16). This constant must be positive or a NumberFormatException will result. The result is made negative if first character of the specified String is the negative sign. No whitespace characters are permitted in the String. @param nm the String to decode. @return the Long represented by the specified string. @exception NumberFormatException if the String does not contain a parsable long. @see java.lang.Long#parseLong(String int)
Class Long, Long getLong(String)

Determines the long value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as a long value and a Long object representing this value is returned. Details of possible numeric formats can be found with the definition of getProperty.

If there is no property with the specified name if the specified name is empty or null or if the property does not have the correct numeric format then null is returned.

In other words this method returns a Long object equal to the value of:

 getLong(nm null) 
@param nm property name. @return the Long value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Class Long, Long getLong(String, Long)

Returns the long value of the system property with the specified name. The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as a long value as per the Long.decode method and a Long object representing this value is returned.

Note that in every case neither L nor l is permitted to appear at the end of the property value as a type indicator as would be permitted in Java programming language source code.

The second argument is the default value. IfThe default value is returned if there is no property of the specified name or if the property does not have the correct numeric format thenor if the second argumentspecified name is returnedempty or null. @param nm property name. @param val default value. @return the Long value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.Long#decode

Class Long, Long getLong(String, long)

Determines the long value of the system property with the specified name.

The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as a long value and a Long object representing this value is returned. Details of possible numeric formats can be found with the definition of getProperty.

IfThe second argument is the default value. A Long object that represents the value of the second argument is returned if there is no property withof the specified name or if the property does not have the correct numeric format then a Long object thator representsif the value ofspecified the second argument is returnedname is empty or null.

In other words this method returns a Long object equal to the value of:

 getLong(nm new Long(val)) 
but in practice it may be implemented in a manner such as:
 Long result = getLong(nm null); return (result == null) new Long(val) : result; 
to avoid the unnecessary allocation of a Long object when the default value is not needed. @param nm property name. @param val default value. @return the Long value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Class Long, String toString(long)

Returns a new String object representing the specified integer. The argument is converted to signed decimal representation and returned as a string exactly as if the argument and the radix 10 were given as arguments to the int) method that takes two arguments. @param i a long to be converted. @return a string representation of the argument in base 10.

Class Math

The class Math contains methods for performing basic numeric operations such as the elementary exponential logarithm square root and trigonometric functions.

To helpUnlike some ensure portability of Java programs the definitions of many of the numeric functions in thisof packageclass requireStrictMath that they produceall implementations of the same results as certain published algorithms. These algorithms are available from theequivalent well-knownfunctions network libraryof class netlib as the package "Freely Distributable Math Library" (fdlibm). These algorithms which are written in the C programming language arenot thendefined to be understood as executed with all floating-point operations followingreturn the rules of Java floatingbit-point arithmetic. Thefor-bit networksame libraryresults. may be foundThis relaxation permits onbetter-performing the World Wide Webimplementations where strict reproducibility at:is not http://metalab.uncrequired.edu/

The Java math library isBy default many of the definedMath withfunctions simply respectdelegate to the versionequivalent offunctions in fdlibmStrictMath dated Januaryfor 4 1995their implementations. WhereCode fdlibmgenerators provides more than oneare encouraged to use definitionplatform-specific for a functionnative libraries or (suchmicroprocessor asinstructions acos)where use theavailable to "IEEEprovide 754higher-performance coreimplementations function"of versionMath (residingfunctions. inSuch ahigher-performance file whose name begins withimplementations still must conform to the letterspecification for eMath). @author unascribed @version 1.39 0450 02/2202/9900 @since JDK1.0

Class Math, double IEEEremainder(double, double)

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The remainder value is mathematically equal to f1 - f2 × n where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2 and if two mathematical integers are equally close to f1/f2 then n is the integer that is even. If the remainder is zero its sign is the same as the sign of the first argument. Special cases: @param f1 the dividend. @param f2 the divisor. @return the remainder when f1 is divided by f2.
Class Math, double abs(double)

Returns the absolute value of a double value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases: In other words the result is equal to the value of the expression:

Double.longBitsToDouble((Double.doubleToLongBits(a)<1)>>>1)
@param a a double value. @return the absolute value of the argument.
Class Math, float abs(float)

Returns the absolute value of a float value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases: In other words the result is equal to the value of the expression:

Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))
@param a a float value. @return the absolute value of the argument.
Class Math, double acos(double)

Returns the arc cosine of an angle in the range of 0.0 through pi. Special case:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the double value whose arc cosine is to be returned. @return the arc cosine of the argument.

Class Math, double asin(double)

Returns the arc sine of an angle in the range of -pi/2 through pi/2. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the double value whose arc sine is to be returned. @return the arc sine of the argument.

Class Math, double atan(double)

Returns the arc tangent of an angle in the range of -pi/2 through pi/2. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the double value whose arc tangent is to be returned. @return the arc tangent of the argument.

Class Math, double atan2(double, double)

Converts rectangular coordinates (b  a) to polar (r  theta). This method computes the phase theta by computing an arc tangent of a/b in the range of -pi to pi. Special cases:

A result must be within 2 ulps of the correctly rounded result. Results must be semi-monotonic. @param a a double value. @param b a double value. @return the theta component of the point (r  theta) in polar coordinates that corresponds to the point (b  a) in Cartesian coordinates.

Class Math, double ceil(double)

Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. Special cases: Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x). @param a a double value. <--@return the value ⌈ a ⌉.--> @return the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.
Class Math, double cos(double)

Returns the trigonometric cosine of an angle. Special case:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the cosine of the argument.

Class Math, double exp(double)

Returns the exponential number e (i.e. 2.718...) raised to the power of a double value. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a a double value. @return the value ea where e is the base of the natural logarithms.

Class Math, double floor(double)

Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. @paramSpecial acases: a @param a ana assigneddouble value. <--@return the value ⌊ a ⌋.--> @return the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.
Class Math, double log(double)

Returns the natural logarithm (base e) of a double value. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a a number greater than 0.0. @return the value ln a the natural logarithm of a.

Class Math, double max(double, double)

Returns the greater of two double values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param a a double value. @param b a double value. @return the larger of a and b.
Class Math, float max(float, float)

Returns the greater of two float values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param a a float value. @param b a float value. @return the larger of a and b.
Class Math, int max(int, int)

Returns the greater of two int values. That is the result is the argument closer to the value of Integer.MAX_VALUE. If the arguments have the same value the result is that same value. @param a an int value. @param b an int value. @return the larger of a and b. @see java.lang.Long#MAX_VALUE
Class Math, long max(long, long)

Returns the greater of two long values. That is the result is the argument closer to the value of Long.MAX_VALUE. If the argumens have the same value the result is that same value. @param a a long value. @param b a long value. @return the larger of a and b. @see java.lang.Long#MAX_VALUE
Class Math, double min(double, double)

Returns the smaller of two double values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param a a double value. @param b a double value. @return the smaller of a and b.
Class Math, float min(float, float)

Returns the smaller of two float values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param a a float value. @param b a float value. @return the smaller of a and b.
Class Math, int min(int, int)

Returns the smaller of two int values. That is the result the argument closer to the value of Integer.MIN_VALUE. If the arguments have the same value the result is that same value. @param a an int value. @param b an int value. @return the smaller of a and b. @see java.lang.Long#MIN_VALUE
Class Math, long min(long, long)

Returns the smaller of two long values. That is the result is the argument closer to the value of Long.MIN_VALUE. If the arguments have the same value the result is that same value. @param a a long value. @param b a long value. @return the smaller of a and b. @see java.lang.Long#MIN_VALUE
Class Math, double pow(double, double)

Returns of value of the first argument raised to the power of the second argument. Special cases:

(In the foregoing descriptions a floating-point value is considered to be an integer if and bonly if it is nota fixed point of the method ceil or which is the same thing a fixed point of the method floor A value is a fixed point of a one-argument method if and only if the result of applying the method to the value is equal to the value.)

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a wholea double value. @param b a double value. @return the numbervalue ab.

Class Math, double random()

Returns a randomdouble numbervalue with a positive sign greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.

When this method is first called it creates a single new pseudorandom-number generator exactly as if by the expression

new java.util.Random
This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else.

This method is properly synchronized to allow correct use by more than one thread. However if many threads need to generate pseudorandom numbers at a great rate it may reduce contention for each thread to have its own pseudorandom-number generator. @return a pseudorandom double greater than or equal to 0.0 and less than 1.0. @see java.util.Random#nextDouble()

Class Math, double rint(double)

returnsReturns the closest integer to the argument. @param a a double value. @returnthat theis closest doublein value to a thatand is equal to a mathematical integer. If two double values that are mathematical integers are equally close to the value of the argument the result is the integer value that is even. Special cases: @param a a double value. @return the closest double value to a that is equal to a mathematical integer.
Class Math, long round(double)

Returns the closest long to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to type long. In other words the result is equal to the value of the expression:

(long)Math.floor(a + 0.5d)

Special cases:

@param a a double value. @return the value of the argument rounded to the nearest long value. @see java.lang.Long#MAX_VALUE @see java.lang.Long#MIN_VALUE
Class Math, int round(float)

Returns the closest int to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to type int. In other words the result is equal to the value of the expression:

(int)Math.floor(a + 0.5f)

Special cases:

@param a a float value. @return the value of the argument rounded to the nearest int value. @see java.lang.Integer#MAX_VALUE @see java.lang.Integer#MIN_VALUE
Class Math, double sin(double)

Returns the trigonometric sine of an angle. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the sine of the argument.

Class Math, double sqrt(double)

Returns the correctly rounded positive square root of a double value. Special cases: Otherwise the result is the double value closest to the true mathetmatical square root of the argument value. @param a a double value. <--@return the value of √ a.--> @return the positive square root of a. If the argument is NaN or less than zero the result is NaN.
Class Math, double tan(double)

Returns the trigonometric tangent of an angle. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the tangent of the argument.

Class Math, double toDegrees(double)

Converts an angle measured in radians to the equivalent angle measured in degrees. @param angrad an angle in radians @return the measurement of the angle angrad in degrees. @since JDK11.2
Class Math, double toRadians(double)

Converts an angle measured in degrees to the equivalent angle measured in radians. @param angdeg an angle in degrees @return the measurement of the angle angdeg in radians. @since JDK11.2

Class NegativeArraySizeException

Thrown if an application tries to create an array with negative size. @author unascribed @version 1.14 0916 02/2102/9800 @since JDK1.0

Class NoClassDefFoundError

Thrown if the Java Virtual Machine or a classloader tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled but the definition can no longer be found. @author unascribed @version 1.15 0917 02/2102/9800 @since JDK1.0


Class NoSuchFieldError

Thrown if an application tries to access or modify a specified field of an object and that object no longer has that field.

Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.7 099 02/2102/9800 @since JDK1.0


Class NoSuchFieldException

Signals that the class doesn't have a field of a specified name. @author unascribed @version 1.8 0911 02/2102/9800 @since JDK1.1
Class NoSuchFieldException, constructor NoSuchFieldException(String)

Constructor with a detail message. @param s the detail message

Class NoSuchMethodError

Thrown if an application tries to call a specified method of a class (either static or instance) and that class no longer has a definition of that method.

Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.16 0918 02/2102/9800 @since JDK1.0


Class NoSuchMethodException

Thrown when a particular method cannot be found. @author unascribed @version 1.8 0910 02/2102/9800 @since JDK1.0

Class NullPointerException

Thrown when an application attempts to use null in a case where an object is required. These include:

Applications should throw instances of this class to indicate other illegal uses of the null object. @author unascribed @version 1.14 0916 02/2102/9800 @since JDK1.0


Class Number

The abstract class Number is the superclass of classes Byte Double Float Integer Long and Short.

Subclasses of Number must provide methods to convert the represented numeric value to byte double float int long and short. @author Lee Boynton @author Arthur van Hoff @version 1.23 0925 02/2102/9800 @see java.lang.Byte @see java.lang.Double @see java.lang.Float @see java.lang.Integer @see java.lang.Long @see java.lang.Short @since JDK1.0


Class NumberFormatException

Thrown to indicate that the application has attempted to convert a string to one of the numeric types but that the string does not have the appropriate format. @author unascribed @version 1.14 0916 02/2102/9800 @see java.lang.Integer#toString() @since JDK1.0

Class Object

Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects including arrays implement the methods of this class. @author unascribed @version 1.49 0454 02/2202/9900 @see java.lang.Class @since JDK1.0
Class Object, void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action including making this object available again to other threads; the usual purpose of finalize however is to perform cleanup actions before the object is irrevocably discarded. For example the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed however that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died including possible actions by other objects or classes which are ready to be finalized at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted but is otherwise ignored. @throws Throwable the Exception raised by this method

Class Object, String toString()

Returns a string representation of the object. In general the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommendedthatrecommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance the at-sign character `@' and the unsigned hexadecimal representation of the hash code of the object. In other words this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode()) 
@return a string representation of the object.
Class Object, void wait(long)

Causes current thread to wait until either another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object all its synchronization claims on the object are restored to the status quo ante - that is to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus on return from the wait method the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

If the current thread is interrupted by another thread while it is waiting then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method as it places the current thread into the wait set for this object unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor. @param timeout the maximum time to wait in milliseconds. @exception IllegalArgumentException if the value of timeout is negative. @exception IllegalMonitorStateException if the current thread is not the owner of the object's monitor. @exception InterruptedException if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown. @see java.lang.Object#notify() @see java.lang.Object#notifyAll()

Class Object, void wait(long, int)

Causes current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object or some other thread interrupts the current thread or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time measured in nanoseconds is given by:

 1000000*millis+nanos

In all other respects this method does the same thing as the method #wait(long) of one argument. In particular wait(0 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

The thread then waits until it can re-obtain ownership of the monitor and resumes execution

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor. @param timeout the maximum time to wait in milliseconds. @param nanonanos additional time in nanoseconds range 0-999999. @exception IllegalArgumentException if the value of timeout is negative or the value of nanos is not in the range 0-999999. @exception IllegalMonitorStateException if the current thread is not the owner of this object's monitor. @exception InterruptedException if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.


Class OutOfMemoryError

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory and no more memory could be made available by the garbage collector. @author unascribed @version 1.16 0918 02/2102/9800 @since JDK1.0

Class Package, Package getPackage(String)

Find a package by name in the callers classloader. The callers classloader is used to find the package instance corresponding to the named class. If the callers classloader is null then the set of packages loaded by the system classloader is searched to find the named package.

Packages have attributes for versions and specifications only if the class loader created the package instance with the appropriate attributes. Typically those attributes are defined in the manifests that accompany the classes. @param packageNamename a package name for example java.lang. @return the package of the requested name. It may be null if no package information is available from the archive or codebase.

Class Package, boolean isSealed(URL)

Returns true if this package is sealed with respect to the specified code source url. @param url the code source url @return true if this package is sealed with respect to url

Class Process

The Runtime.exec methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it. The class Process provides methods for performing input from the process performing output to the process waiting for the process to complete checking the exit status of the process and destroying (killing) the process.

The Runtime.exec methods may not work well for special processes on certain native platforms such as native windowing processes daemon processes Win16/DOS processes on Win32 or shell scripts. The created subprocess does not have its own terminal or console. All its standard io (i.e. stdin stdout stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream() Process.getInputStream() Process.getErrorStream()). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block and even deadlock.

The subprocess is not killed when there are no more references to the Process object but rather the subprocess continues executing asynchronously.

There is no requirement that a process represented by a Process object execute asynchronously or concurrently with respect to the Java process that owns the Process object. @author unascribed @version 1.15 0817 02/2602/9800 @see java.lang.Runtime#exec(java.lang.String) @see java.lang.Runtime#exec(java.lang.String java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[] java.lang.String[]) @since JDK1.0


Class Runnable

The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run.

This interface is designed to provide a common protocol for objects that wish to execute code while they are active. For example Runnable is implemented by class Thread. Being active simply means that a thread has been started and has not yet been stopped.

In addition Runnable provides the means for a class to be active while not subclassing Thread. A class that implements Runnable can run without subclassing Thread by instantiating a Thread instance and passing itself in as the target. In most cases the Runnable interface should be used if you are only planning to override the run() method and no other Thread methods. This is important because classes should not be subclassed unless the programmer intends on modifying or enhancing the fundamental behavior of the class. @author Arthur van Hoff @version 1.19 0921 02/2102/9800 @see java.lang.Thread @since JDK1.0


Class Runtime

Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getRuntime method.

An application cannot create its own instance of this class. @author unascribed @version 1.48 0456 03/2620/00 @see java.lang.Runtime#getRuntime() @since JDK1.0

Class Runtime, Process exec(String)

Executes the specified string command in a separate process.

The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a java.util.StringTokenizer created by the call:

 new StringTokenizer(command) 
with no further modifications of the character categories. This method has exactly the same effect as exec(command null). @param command a specified system command. @return a Process object for managing the subprocess. @exception SecurityException if a security manager exists and its checkExec method doesn't allow creation of a subprocess. @exception IOException if an I/O error occurs @see java.lang.Runtime#exec(java.lang.String java.lang.String[]) @see java.lang.SecurityManager#checkExec(java.lang.String)
Class Runtime, Process exec(String, String[])

Executes the specified string command in a separate process with the specified environment.

This method breaks the command string into tokens and creates a new array cmdarray containing the tokens in the order that they were produced by the string tokenizer; it then performs the call exec(cmdarray envp). The token parsing is done by a java.util.StringTokenizer created by the call:

 new StringTokenizer(command) 
with no further modification of the character categories.

The environment variable settings are specified by envp. If envp is null the subprocess inherits the environment settings of the current process. @param commandcmd a specified system command. @param envp array of strings each element of which has environment variable settings in format name=value. @return a Process object for managing the subprocess. @exception SecurityException if a security manager exists and its checkExec method doesn't allow creation of a subprocess. @exception IOException if an I/O error occurs @see java.lang.Runtime#exec(java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[] java.lang.String[]) @see java.lang.SecurityManager#checkExec(java.lang.String)

Class Runtime, void exit(int)

Terminates the currently running Java Virtualvirtual Machinemachine by initiating its shutdown sequence. This method never returns normally. The argument serves as a status code; by convention a nonzero status code indicates abnormal termination.

FirstThe virtual machine's shutdown sequence constists of two phases. In the first phase all registered shutdow hooks} if any are started in some unspecified order and allowed to run concurrently until they finish. In the second phase all uninvoked finalizers are run if therefinalization-on-exit has been enabled. Once this is a security manager itsdone the virtual machine checkExithalts

If this method is called withinvoked after the statusvirtual asmachine has begun its argument.shutdown This may result in asequence then if shutdown hooks securityare being run this method will exceptionblock indefinitely. The argument serves as a statusIf shutdown hooks have already been run code;and byon-exit convention afinalization has nonzerobeen enabled then this method halts the virtual machine with the given status code indicates abnormalif the terminationstatus is nonzero; otherwise it blocks indefinitely.

The method{@link System#exit(int) System.exit} method is the conventional and convenient means of invoking this method.

@param status exitTermination status. By convention a nonzero status code indicates abnormal termination. @throws SecurityException ifIf a security manager existsis present and its {@link SecurityManager#checkExit checkExit} method doesn'tdoes allownot exitpermit exiting with the specified status. @see java.lang.SecurityException @see java.lang.SecurityManager#checkExit(int) @see #addShutdownHook @see #removeShutdownHook @see #runFinalizersOnExit @see #halt(int)

Class Runtime, InputStream getLocalizedInputStream(InputStream)

Creates a localized version of an input stream. This method takes an InputStream and returns an InputStream equivalent to the argument in all respects except that it is localized: as characters in the local character set are read from the stream they are automatically converted from the local character set to Unicode.

If the argument is already a localized stream it may be returned as the result. @param in InputStream to localize @return a localized input stream @see java.io.InputStream @see java.io.BufferedReader#BufferedReader(java.io.Reader) @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream) @deprecated As of JDK 1.1 the preferred way translate a byte stream in the local encoding into a character stream in Unicode is via the InputStreamReader and BufferedReader classes. @return a localized input stream. @see java.io.InputStream @see java.io.BufferedReader#BufferedReader(java.io.Reader) @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream)

Class Runtime, OutputStream getLocalizedOutputStream(OutputStream)

Creates a localized version of an output stream. This method takes an OutputStream and returns an OutputStream equivalent to the argument in all respects except that it is localized: as Unicode characters are written to the stream they are automatically converted to the local character set.

If the argument is already a localized stream it may be returned as the result. @deprecated As of JDK 1.1 the preferred way to translate a Unicode character stream into a byte stream in the local encoding is via the OutputStreamWriter BufferedWriter and PrintWriter classes. @param out OutputStream to localize @return a localized output stream. @see java.io.OutputStream @see java.io.BufferedWriter#BufferedWriter(java.io.Writer) @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream) @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)

Class Runtime, void runFinalizersOnExit(boolean)

Enable or disable finalization on exit; doing so specifies that the finalizers of all objects that have finalizers that have not yet been automatically invoked are to be run before the Java runtime exits. By default finalization on exit is disabled.

If there is a security manager its checkExit method is first called with 0 as its argument to ensure the exit is allowed. This could result in a SecurityException. @param value true to enable finalization on exit false to disable @deprecated This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects resulting in erratic behavior or deadlock. @throws SecurityException if a security manager exists and its checkExit method doesn't allow the exit. @see java.lang.Runtime#exit(int) @see java.lang.Runtime#gc() @see java.lang.SecurityManager#checkExit(int) @since JDK1.1


Class RuntimeException

RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine.

A method is not required to declare in its throws clause any subclasses of RuntimeException that might be thrown during the execution of the method but not caught. @author Frank Yellin @version 1.7 099 02/2102/9800 @since JDK1.0


Class RuntimePermission

This class is for runtime permissions. A RuntimePermission contains a name (also referred to as a "target name") but no actions list; you either have the named permission or you don't.

The target name is the name of the runtime permission (see below). The naming convention follows the hierarchical property naming convention. Also an asterisk may appear at the end of the name following a "." or by itself to signify a wildcard match. For example: "loadLibrary.*" or "*" is valid "*loadLibrary" or "a*b" is not valid.

The following table lists all the possible RuntimePermission target names and for each provides a description of what the permission allows and a discussion of the risks of granting code the permission.

Permission Target Name What the Permission Allows Risks of Allowing this Permission
createClassLoader Creation of a class loader This is an extremely dangerous permission to grant. Malicious applications that can instantiate their own class loaders could then load their own rogue classes into the system. These newly loaded classes could be placed into any protection domain by the class loader thereby automatically granting the classes the permissions for that domain.
getClassLoader Retrieval of a class loader (e.g. the class loader for the calling class) This would grant an attacker permission to get the class loader for a particular class. This is dangerous because having access to a class's class loader allows the attacker to load other classes available to that class loader. The attacker would typically otherwise not have access to those classes.
setContextClassLoader Setting of the context class loader used by a thread The context class loader is used by system code and extensions when they need to lookup resources that might not exist in the system class loader. Granting setContextClassLoader permission would allow code to change which context class loader is used for a particular thread including system threads.
setSecurityManager Setting of the security manager (possibly replacing an existing one) The security manager is a class that allows applications to implement a security policy. Granting the setSecurityManager permission would allow code to change which security manager is used by installing a different possibly less restrictive security manager thereby bypassing checks that would have been enforced by the original security manager.
createSecurityManager Creation of a new security manager This gives code access to protected sensitive methods that may disclose information about other classes or the execution stack.
exitVM Halting of the Java Virtual Machine This allows an attacker to mount a denial-of-service attack by automatically forcing the virtual machine to halt.
shutdownHooks Registration and cancellation of virtual-machine shutdown hooks This allows an attacker to register a malicious shutdown hook that interferes with the clean shutdown of the virtual machine.
setFactory Setting of the socket factory used by ServerSocket or Socket or of the stream handler factory used by URL This allows code to set the actual implementation for the socket server socket stream handler or RMI socket factory. An attacker may set a faulty implementation which mangles the data stream.
setIO Setting of System.out System.in and System.err This allows changing the value of the standard system streams. An attacker may change System.in to monitor and steal user input or may set System.err to a "null" OutputSteam which would hide any error messages sent to System.err.
modifyThread Modification of threads e.g. via calls to Thread stop suspend resume setPriority and setName methods This allows an attacker to start or suspend any thread in the system.
stopThread Stopping of threads via calls to the Thread stop method This allows code to stop any thread in the system provided that it is already granted permission to access that thread. This poses as a threat because that code may corrupt the system by killing existing threads.
modifyThreadGroup modification of thread groups e.g. via calls to ThreadGroup destroy getParent resume setDaemon setMaxPriority stop and suspend methods This allows an attacker to create thread groups and set their run priority.
getProtectionDomain Retrieval of the ProtectionDomain for a class This allows code to obtain policy information for a particular code source. While obtaining policy information does not compromise the security of the system it does give attackers additional information such as local file names for example to better aim an attack.
readFileDescriptor Reading of file descriptors This would allow code to read the particular file associated with the file descriptor read. This is dangerous if the file contains confidential data.
writeFileDescriptor Writing to file descriptors This allows code to write to a particular file associated with the descriptor. This is dangerous because it may allow malicous code to plant viruses or at the very least fill up your entire disk.
loadLibrary.{library name} Dynamic linking of the specified library It is dangerous to allow an applet permission to load native code libraries because the Java security architecture is not designed to and does not prevent malicious behavior at the level of native code.
accessClassInPackage.{package name} Access to the specified package via a class loader's loadClass method when that class loader calls the SecurityManager checkPackageAcesss method This gives code access to classes in packages to which it normally does not have access. Malicious code may use these classes to help in its attempt to compromise security in the system.
defineClassInPackage.{package name} Definition of classes in the specified package via a class loader's defineClass method when that class loader calls the SecurityManager checkPackageDefinition method. This grants code permission to define a class in a particular package. This is dangerous because malicious code with this permission may define rogue classes in trusted packages like java.security or java.lang for example.
accessDeclaredMembers Access to the declared members of a class This grants code permission to query a class for its public protected default (package) access and private fields and/or methods. Although the code would have access to the private and protected field and method names it would not have access to the private/protected field data and would not be able to invoke any private methods. Nevertheless malicious code may use this information to better aim an attack. Additionally it may invoke any public methods and/or access public fields in the class. This could be dangerous if the code would normally not be able to invoke those methods and/or access the fields because it can't cast the object to the class/interface with those methods and fields.
queuePrintJob Initiation of a print job request This could print sensitive information to a printer or simply waste paper.
@see java.security.BasicPermission @see java.security.Permission @see java.security.Permissions @see java.security.PermissionCollection @see java.lang.SecurityManager @version 1.33 9937 00/0402/2202 @author Marianne Mueller @author Roland Schemers


Class SecurityException

Thrown by the security manager to indicate a security violation. @author unascribed @version 1.9 0911 02/2102/9800 @see java.lang.SecurityManager @since JDK1.0

Class SecurityManager

The security manager is a class that allows applications to implement a security policy. It allows an application to determine before performing a possibly unsafe or sensitive operation what the operation is and whether it is being attempted in a security context that allows the operation to be performed. The application can allow or disallow the operation.

The SecurityManager class contains many methods with names that begin with the word check. These methods are called by various methods in the Java libraries before those methods perform certain potentially sensitive operations. The invocation of such a check method typically looks like this:

 SecurityManager security = System.getSecurityManager(); if (security = null) { security.checkXXX(argument  . . . ); } 

The security manager is thereby given an opportunity to prevent completion of the operation by throwing an exception. A security manager routine simply returns if the operation is permitted but throws a SecurityException if the operation is not permitted. The only exception to this convention is checkTopLevelWindow which returns a boolean value.

The current security manager is set by the setSecurityManager method in class System. The current security manager is obtained by the getSecurityManager method.

The special method SecurityManager#checkPermission(java.security.Permission) determines whether an access request indicated by a specified permission should be granted or denied. The default implementation calls

 AccessController.checkPermission(perm); 

If a requested access is allowed checkPermission returns quietly. If denied a SecurityException is thrown.

As of JDKJava 12 SDK v1.2 the default implementation of each of the other check methods in SecurityManager is to call the SecurityManager checkPermission method to determine if the calling thread has permission to perform the requested operation.

Note that the checkPermission method with just a single permission argument always performs security checks within the context of the currently executing thread. Sometimes a security check that should be made within a given context will actually need to be done from within a different context (for example from within a worker thread). The getSecurityContext method and the java.lang.Object checkPermission} method that includes a context argument are provided for this situation. The getSecurityContext method returns a "snapshot" of the current calling context. (The default implementation returns an AccessControlContext object.) A sample call is the following:

 Object context = null; SecurityManager sm = System.getSecurityManager(); if (sm = null) context = sm.getSecurityContext(); 

The checkPermission method that takes a context object in addition to a permission makes access decisions based on that context rather than on that of the current execution thread. Code within a different context can thus call that method passing the permission and the previously-saved context object. A sample call using the SecurityManager sm obtained as in the previous example is the following:

 if (sm = null) sm.checkPermission(permission context); 

Permissions fall into these categories: File Socket Net Security Runtime Property AWT Reflect and Serializable. The classes managing these various permission categories are java.io.FilePermission java.net.SocketPermission java.net.NetPermission java.security.SecurityPermission java.lang.RuntimePermission java.util.PropertyPermission java.awt.AWTPermission java.lang.reflect.ReflectPermission and java.io.SerializablePermission.

All but the first two (FilePermission and SocketPermission) are subclasses of java.security.BasicPermission which itself is an abstract subclass of the top-level class for permissions which is java.security.Permission. BasicPermission defines the functionality needed for all permissions that contain a name that follows the hierarchical property naming convention (for example "exitVM" "setFactory" "queuePrintJob" etc). An asterisk may appear at the end of the name following a "." or by itself to signify a wildcard match. For example: "a.*" or "*" is valid "*a" or "a*b" is not valid.

FilePermission and SocketPermission are subclasses of the top-level class for permissions (java.security.Permission). Classes like these that have a more complicated name syntax than that used by BasicPermission subclass directly from Permission rather than from BasicPermission. For example for a java.io.FilePermission object the permission name is the pathname of a file (or directory).

Some of the permission classes have an "actions" list that tells the actions that are permitted for the object. For example for a java.io.FilePermission object the actions list (such as "read write") specifies which actions are granted for the specified file (or for files in the specified directory).

Other permission classes are for "named" permissions - ones that contain a name but no actions list; you either have the named permission or you don't.

Note: There is also a java.security.AllPermission permission that implies all permissions. It exists to simplify the work of system administrators who might need to perform multiple tasks that require all (or numerous) permissions.

See Permissions in JDK1.the Java 2 SDK for permission-related information. This document includes for example a table listing the various SecurityManager check methods and the permission(s) the default implementation of each such method requires. It also contains a table of all the JDKversion 1.2 methods that require permissions and for each such method tells which permission it requires.

For more information about SecurityManager changes made in JDKthe 1.Java 2 SDK and advice regarding porting of 1.1-style security managers see the releasesecurity documentation at http://java.sun.com/products/jdk/1.2/docs/guide/security/index.html. @author Arthur van Hoff @author Roland Schemers @version 1.107 04121 02/2202/9900 @see java.lang.ClassLoader @see java.lang.SecurityException @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object) checkTopLevelWindow @see java.lang.System#getSecurityManager() getSecurityManager @see java.lang.System#setSecurityManager(java.lang.SecurityManager) setSecurityManager @see java.security.AccessController AccessController @see java.security.AccessControlContext AccessControlContext @see java.security.AccessControlException AccessControlException @see java.security.Permission @see java.security.BasicPermission @see java.io.FilePermission @see java.net.SocketPermission @see java.util.PropertyPermission @see java.lang.RuntimePermission @see java.awt.AWTPermission @see java.security.Policy Policy @see java.security.SecurityPermission SecurityPermission @see java.security.ProtectionDomain @since JDK1.0

Class SecurityManager, void checkAccept(String, int)

Throws a SecurityException if the calling thread is not permitted to accept a socket connection from the specified host and port number.

This method is invoked for the current security manager by the accept method of class ServerSocket.

This method calls checkPermission with the SocketPermission(host+":"+port "accept") permission.

If you override this method then you should make a call to super.checkAccept at the point the overridden method would normally throw an exception. @param host the host name of the socket connection. @param port the port number of the socket connection. @exception SecurityException if the calling thread does not have permission to accept the connection. @exception NullPointerException if the host argument is null. @see java.net.ServerSocket#accept() @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkAccess(Thread)

Throws a SecurityException if the calling thread is not allowed to modify the thread argument.

This method is invoked for the current security manager by the stop suspend resume setPriority setName and setDaemon methods of class Thread.

If the thread argument is a system thread (belongs to the thread group with a null parent) then this method calls checkPermission with the RuntimePermission("modifyThread") permission. If the thread argument is not a system thread this method just returns silently.

Applications that want a stricter policy should override this method. If this method is overridden the method that overrides it should additionally check to see if the calling thread has the RuntimePermission("modifyThread") permission and if so return silently. This is to ensure that code granted that permission (such as the JDKSDK itself) is allowed to manipulate any thread.

If this method is overridden then super.checkAccess should be called by the first statement in the overridden method or the equivalent security check should be placed in the overridden method. @param t the thread to be checked. @exception SecurityException if the calling thread does not have permission to modify the thread. @exception NullPointerException if the thread argument is null. @see java.lang.Thread#resume() resume @see java.lang.Thread#setDaemon(boolean) setDaemon @see java.lang.Thread#setName(java.lang.String) setName @see java.lang.Thread#setPriority(int) setPriority @see java.lang.Thread#stop() stop @see java.lang.Thread#suspend() suspend @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkAccess(ThreadGroup)

Throws a SecurityException if the calling thread is not allowed to modify the thread group argument.

This method is invoked for the current security manager when a new child thread or child thread group is created and by the setDaemon setMaxPriority stop suspend resume and destroy methods of class ThreadGroup.

If the thread group argument is the system thread group ( has a null parent) then this method calls checkPermission with the RuntimePermission("modifyThreadGroup") permission. If the thread group argument is not the system thread group this method just returns silently.

Applications that want a stricter policy should override this method. If this method is overridden the method that overrides it should additionally check to see if the calling thread has the RuntimePermission("modifyThreadGroup") permission and if so return silently. This is to ensure that code granted that permission (such as the JDKSDK itself) is allowed to manipulate any thread.

If this method is overridden then super.checkAccess should be called by the first statement in the overridden method or the equivalent security check should be placed in the overridden method. @param g the thread group to be checked. @exception SecurityException if the calling thread does not have permission to modify the thread group. @exception NullPointerException if the thread group argument is null. @see java.lang.ThreadGroup#destroy() destroy @see java.lang.ThreadGroup#resume() resume @see java.lang.ThreadGroup#setDaemon(boolean) setDaemon @see java.lang.ThreadGroup#setMaxPriority(int) setMaxPriority @see java.lang.ThreadGroup#stop() stop @see java.lang.ThreadGroup#suspend() suspend @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkConnect(String, int)

Throws a SecurityException if the calling thread is not allowed to open a socket connection to the specified host and port number.

A port number of -1 indicates that the calling method is attempting to determine the IP address of the specified host name.

This method calls checkPermission with the SocketPermission(host+":"+port "connect") permission if the port is not equal to -1. If the port is equal to -1 then it calls checkPermission with the SocketPermission(host "resolve") permission.

If you override this method then you should make a call to super.checkConnect at the point the overridden method would normally throw an exception. @param host the host name port to connect to. @param port the protocol port to connect to. @exception SecurityException if the calling thread does not have permission to open a socket connection to the specified host and port. @exception NullPointerException if the host argument is null. @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkConnect(String, int, Object)

Throws a SecurityException if the specified security context is not allowed to open a socket connection to the specified host and port number.

A port number of -1 indicates that the calling method is attempting to determine the IP address of the specified host name.

If context is not an instance of AccessControlContext then a SecurityException is thrown.

Otherwise the port number is checked. If it is not equal to -1 the context's checkPermission method is called with a SocketPermission(host+":"+port "connect") permission. If the port is equal to -1 then the context's checkPermission method is called with a SocketPermission(host "resolve") permission.

If you override this method then you should make a call to super.checkConnect at the point the overridden method would normally throw an exception. @param host the host name port to connect to. @param port the protocol port to connect to. @param context a system-dependent security context. @exception SecurityException if the specified security context is not an instance of AccessControlContext (e.g. is null) or does not have permission to open a socket connection to the specified host and port. @exception NullPointerException if the host argument is null. @see java.lang.SecurityManager#getSecurityContext() @see java.security.AccessControlContext#checkPermission(java.security.Permission)

Class SecurityManager, void checkDelete(String)

Throws a SecurityException if the calling thread is not allowed to delete the specified file.

This method is invoked for the current security manager by the delete method of class File.

This method calls checkPermission with the FilePermission(file "delete") permission.

If you override this method then you should make a call to super.checkDelete at the point the overridden method would normally throw an exception. @param file the system-dependent filename. @exception SecurityException if the calling thread does not have permission to delete the file. @exception NullPointerException if the file argument is null. @see java.io.File#delete() @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkExec(String)

Throws a SecurityException if the calling thread is not allowed to create a subprocess.

This method is invoked for the current security manager by the exec methods of class Runtime.

This method calls checkPermission with the FilePermission(cmd "execute") permission if cmd is an absolute path otherwise it calls checkPermission with FilePermission("<<ALL FILES>>" "execute").

If you override this method then you should make a call to super.checkExec at the point the overridden method would normally throw an exception. @param cmd the specified system command. @exception SecurityException if the calling thread does not have permission to create a subprocess. @exception NullPointerException if the cmd argument is null. @see java.lang.Runtime#exec(java.lang.String) @see java.lang.Runtime#exec(java.lang.String java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[] java.lang.String[]) @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkLink(String)

Throws a SecurityException if the calling thread is not allowed to dynamic link the library code specified by the string argument file. The argument is either a simple library name or a complete filename.

This method is invoked for the current security manager by methods load and loadLibrary of class Runtime.

This method calls checkPermission with the RuntimePermission("loadLibrary."+lib) permission.

If you override this method then you should make a call to super.checkLink at the point the overridden method would normally throw an exception. @param lib the name of the library. @exception SecurityException if the calling thread does not have permission to dynamically link the library. @exception NullPointerException if the lib argument is null. @see java.lang.Runtime#load(java.lang.String) @see java.lang.Runtime#loadLibrary(java.lang.String) @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkMemberAccess(Class, int)

Throws a SecurityException if the calling thread is not allowed to access members.

The default policy is to allow access to PUBLIC members as well as access to classes that have the same class loader as the caller. In all other cases this method calls checkPermission with the RuntimePermission("accessDeclaredMembers") permission.

If this method is overridden then a call to super.checkMemberAccess cannot be made as the default implementation of checkMemberAccess relies on the code being checked being at a stack depth of 4. @param clazz the class that reflection is to be performed on. @param which type of access PUBLIC or DECLARED. @exception SecurityException if the caller does not have permission to access members. @exception NullPointerException if the clazz argument is null. @see java.lang.reflect.Member @since JDK1.1 @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkMulticast(InetAddress)

Throws a SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast.

This method calls checkPermission with the java.net.SocketPermission(maddr.getHostAddress() "accept connect") permission.

If you override this method then you should make a call to super.checkMulticast at the point the overridden method would normally throw an exception. @param maddr Internet group address to be used. @exception SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast. @exception NullPointerException if the address argument is null. @since JDK1.1 @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkMulticast(InetAddress, byte)

Throws a SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast.

This method calls checkPermission with the java.net.SocketPermission(maddr.getHostAddress() "accept connect") permission.

If you override this method then you should make a call to super.checkMulticast at the point the overridden method would normally throw an exception. @param maddr Internet group address to be used. @param ttl value in use if it is multicast send. Note: this particular implementation does not use the ttl parameter. @exception SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast. @exception NullPointerException if the address argument is null. @since JDK1.1 @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkPackageAccess(String)

Throws a SecurityException if the calling thread is not allowed to access the package specified by the argument.

This method is used by the loadClass method of class loaders.

This method first gets a list of restricted packages by obtaining a comma-separated list from a call to java.security.Security.getProperty("package.access") and checks to see if pkg starts with or equals any of the restricted packages. If it does then checkPermission gets called with the RuntimePermission("accessClassInPackage."+pkg) permission.

If this method is overridden then super.checkPackageAccess should be called as the first line in the overridden method. @param pkg the package name. @exception SecurityException if the calling thread does not have permission to access the specified package. @exception NullPointerException if the package name argument is null. @see java.lang.ClassLoader#loadClass(java.lang.String boolean) loadClass @see java.security.Security#getProperty getProperty @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkPermission(Permission)

Throws a SecurityException if the requested access specified by the given permission is not permitted based on the security policy currently in effect.

This method calls AccessController.checkPermission with the given permission. @param perm the requested permission. @exception SecurityException if access is not permitted based on the current security policy. @exception NullPointerException if the permission argument is null. @since JDK11.2

Class SecurityManager, void checkPermission(Permission, Object)

Throws a SecurityException if the specified security context is denied access to the resource specified by the given permission. The context must be a security context returned by a previous call to getSecurityContext and the access control decision is based upon the configured security policy for that security context.

If context is an instance of AccessControlContext then the AccessControlContext.checkPermission method is invoked with the specified permission.

If context is not an instance of AccessControlContext then a SecurityException is thrown. @param perm the specified permission @param context a system-dependent security context. @exception SecurityException if the specified security context is not an instance of AccessControlContext (e.g. is null) or is denied access to the resource specified by the given permission. @exception NullPointerException if the permission argument is null. @see java.lang.SecurityManager#getSecurityContext() @see java.security.AccessControlContext#checkPermission(java.security.Permission) @since JDK11.2

Class SecurityManager, void checkPropertyAccess(String)

Throws a SecurityException if the calling thread is not allowed to access the system property with the specified key name.

This method is used by the getProperty method of class System.

This method calls checkPermission with the PropertyPermission(key "read") permission.

If you override this method then you should make a call to super.checkPropertyAccess at the point the overridden method would normally throw an exception. @param key a system property key. @exception SecurityException if the calling thread does not have permission to access the specified system property. @exception NullPointerException if the key argument is null. @exception IllegalArgumentException if key is empty. @see java.lang.System#getProperty(java.lang.String) @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkRead(FileDescriptor)

Throws a SecurityException if the calling thread is not allowed to read from the specified file descriptor.

This method calls checkPermission with the RuntimePermission("readFileDescriptor") permission.

If you override this method then you should make a call to super.checkRead at the point the overridden method would normally throw an exception. @param fd the system-dependent file descriptor. @exception SecurityException if the calling thread does not have permission to access the specified file descriptor. @exception NullPointerException if the file descriptor argument is null. @see java.io.FileDescriptor @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkRead(String)

Throws a SecurityException if the calling thread is not allowed to read the file specified by the string argument.

This method calls checkPermission with the FilePermission(file "read") permission.

If you override this method then you should make a call to super.checkRead at the point the overridden method would normally throw an exception. @param file the system-dependent file name. @exception SecurityException if the calling thread does not have permission to access the specified file. @exception NullPointerException if the file argument is null. @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkRead(String, Object)

Throws a SecurityException if the specified security context is not allowed to read the file specified by the string argument. The context must be a security context returned by a previous call to getSecurityContext.

If context is an instance of AccessControlContext then the AccessControlContext.checkPermission method will be invoked with the FilePermission(file "read") permission.

If context is not an instance of AccessControlContext then a SecurityException is thrown.

If you override this method then you should make a call to super.checkRead at the point the overridden method would normally throw an exception. @param file the system-dependent filename. @param context a system-dependent security context. @exception SecurityException if the specified security context is not an instance of AccessControlContext (e.g. is null) or does not have permission to read the specified file. @exception NullPointerException if the file argument is null. @see java.lang.SecurityManager#getSecurityContext() @see java.security.AccessControlContext#checkPermission(java.security.Permission)

Class SecurityManager, void checkSecurityAccess(String)

Determines whether the permission with the specified permission target name should be granted or denied.

If the requested permission is allowed this method returns quietly. If denied a SecurityException is raised.

This method creates a SecurityPermission object for the given permission target name and calls checkPermission with it.

See the documentation for {@link java.security.SecurityPermission} for a list of possible permission target names.

If you override this method then you should make a call to super.checkSecurityAccess at the point the overridden method would normally throw an exception. @param target the target name of the SecurityPermission. @exception SecurityException if the calling thread does not have permission for the requested access. @exception NullPointerException if target is null. @exception IllegalArgumentException if target is empty. @since JDK1.1 @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, boolean checkTopLevelWindow(Object)

Returns false if the calling thread is not trusted to bring up the top-level window indicated by the window argument. In this case the caller can still decide to show the window but the window should include some sort of visual warning. If the method returns true then the window can be shown without any special restrictions.

See class Window for more information on trusted and untrusted windows.

This method calls checkPermission with the AWTPermission("showWindowWithoutWarningBanner") permission and returns true if a SecurityException is not thrown otherwise it returns false.

If you override this method then you should make a call to super.checkTopLevelWindow at the point the overridden method would normally return false and the value of super.checkTopLevelWindow should be returned. @param window the new window that is being created. @return true if the calling thread is trusted to put up top-level windows; false otherwise. @exception SecurityException if creation is disallowed entirely. @exception NullPointerException if the window argument is null. @see java.awt.Window @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkWrite(FileDescriptor)

Throws a SecurityException if the calling thread is not allowed to write to the specified file descriptor.

This method calls checkPermission with the RuntimePermission("writeFileDescriptor") permission.

If you override this method then you should make a call to super.checkWrite at the point the overridden method would normally throw an exception. @param fd the system-dependent file descriptor. @exception SecurityException if the calling thread does not have permission to access the specified file descriptor. @exception NullPointerException if the file descriptor argument is null. @see java.io.FileDescriptor @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, void checkWrite(String)

Throws a SecurityException if the calling thread is not allowed to write to the file specified by the string argument.

This method calls checkPermission with the FilePermission(file "write") permission.

If you override this method then you should make a call to super.checkWrite at the point the overridden method would normally throw an exception. @param file the system-dependent filename. @exception SecurityException if the calling thread does not have permission to access the specified file. @exception NullPointerException if the file argument is null. @see #checkPermission(java.security.Permission) checkPermission

Class SecurityManager, ThreadGroup getThreadGroup()

Returns the thread group into which to instantiate any new thread being created at the time this is being called. By default it returns the thread group of the current thread. This should be overridden by a specific security manager to return the appropriate thread group. @return ThreadGroup that new threads are instantiated into @since JDK1.1 @see java.lang.ThreadGroup

Class Short

The Short class is the standard wrapper for short values. @author Nakul Saraiya @version 1.15 0822 02/0302/9800 @see java.lang.Number @since JDK1.1
Class Short, int compareTo(Object)

Compares this Short to another Object. If the Object is a Short this function behaves like compareTo(Short). Otherwise it throws a ClassCastException (as Shorts are comparable only to other Shorts). @param o the Object to be compared. @return the value 0 if the argument is a Short numerically equal to this Short; a value less than 0 if the argument is a Short numerically greater than this Short; and a value greater than 0 if the argument is a Short numerically less than this Short. @exception ClassCastException if the argument is not a Short. @see java.lang.Comparable @since JDK11.2
Class Short, int compareTo(Short)

Compares two Shorts numerically. @param anotherShort the Short to be compared. @return the value 0 if the argument Short is equal to this Short; a value less than 0 if this Short is numerically less than the Short argument; and a value greater than 0 if this Short is numerically greater than the Short argument (signed comparison). @since JDK11.2
Class Short, Short decode(String)

Decodes a String into a Short. Accepts decimal hexadecimal and octal numbers in the following formats:
 [-] decimal constant [-] 0x hex constant [-] # hex constant [-] 0 octal constant 
The constant following an (optional) negative sign and/or "radix specifier" is parsed as by the Short.parseShort method with the specified radix (10 8 or 16). This constant must be positive or a NumberFormatException will result. The result is made negative if first character of the specified String is the negative sign. No whitespace characters are permitted in the String. @param nm the String to decode. @return the Short represented by the specified string. @exception NumberFormatException if the String does not contain a parsable short. @see java.lang.Short#parseShort(String int)
Class Short, short parseShort(String)

Assuming the specified String represents a short returns that short's value. Throws an exception if the String cannot be parsed as a short. The radix is assumed to be 10. @param s the String containing the short @return short the value represented by the specified string @exception NumberFormatException If the string does not contain a parsable short.
Class Short, short parseShort(String, int)

Assuming the specified String represents a short returns that short's value. Throws an exception if the String cannot be parsed as a short. @param s the String containing the short @param radix the radix to be used @return The short value represented by the specified string in the specified radix. @exception NumberFormatException If the String does not contain a parsable short.
Class Short, String toString(short)

Returns a new String object representing the specified Short. The radix is assumed to be 10. @param s the short to be converted @return The String that represents the specified short in radix 10.
Class Short, Short valueOf(String)

Assuming the specified String represents a short returns a new Short object initialized to that value. Throws an exception if the String cannot be parsed as a short. @param s the String containing the integer @return Short of the value represented by the specified string in radix 10. @exception NumberFormatException If the String does not contain a parsable short.
Class Short, Short valueOf(String, int)

Assuming the specified String represents a short returns a new Short object initialized to that value. Throws an exception if the String cannot be parsed as a short. @param s the String containing the integer @param radix the radix to be used @return The Short value represented by the specified string in the specified radix. @exception NumberFormatException If the String does not contain a parsable short.

Class StackOverflowError

Thrown when a stack overflow occurs because an application recurses too deeply. @author unascribed @version 1.16 0918 02/2102/9800 @since JDK1.0

Class String

The String class represents character strings. All string literals in Java programs such as "abc" are implemented as instances of this class.

Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:

 String str = "abc"; 

is equivalent to:

 char data[] = {'a' 'b' 'c'}; String str = new String(data); 

Here are some more examples of how strings can be used:

 System.out.println("abc"); String cde = "cde"; System.out.println("abc" + cde); String c = "abc".substring(2 3); String d = cde.substring(1 2); 

The class String includes methods for examining individual characters of the sequence for comparing strings for searching strings for extracting substrings and for creating a copy of a string with all characters translated to uppercase or to lowercase.

The Java language provides special support for the string concatentation operator ( + ) and for conversion of other objects to strings. String concatenation is implemented through the StringBuffer class and its append method. String conversions are implemented through the method toString defined by Object and inherited by all classes in Java. For additional information on string concatenation and conversion see Gosling Joy and Steele The Java Language Specification. @author Lee Boynton @author Arthur van Hoff @version 1.114 04121 10/2206/99 @see java.lang.Object#toString() @see java.lang.StringBuffer @see java.lang.StringBuffer#append(boolean) @see java.lang.StringBuffer#append(char) @see java.lang.StringBuffer#append(char[]) @see java.lang.StringBuffer#append(char[] int int) @see java.lang.StringBuffer#append(double) @see java.lang.StringBuffer#append(float) @see java.lang.StringBuffer#append(int) @see java.lang.StringBuffer#append(long) @see java.lang.StringBuffer#append(java.lang.Object) @see java.lang.StringBuffer#append(java.lang.String) @see Character encodings @since JDK1.0

Class String, constructor String(byte[], String)

Construct a new String by converting the specified array of bytes using the specified character encoding. The length of the new String is a function of the encoding and hence may not be equal to the length of the byte array. @param bytes The bytes to be converted into characters @param enc AThe name of a supported character-encoding nameencoding @exception UnsupportedEncodingException If the named encoding is not supported @since JDK1.1
Class String, constructor String(byte[], int, int, String)

Construct a new String by converting the specified subarray of bytes using the specified character encoding. The length of the new String is a function of the encoding and hence may not be equal to the length of the subarray. @param bytes The bytes to be converted into characters @param offset Index of the first byte to convert @param length Number of bytes to convert @param enc The name of a supported character encoding @exceptionthrows UnsupportedEncodingException Ifif the named encoding is not supported @throws IndexOutOfBoundsException if the offset and count arguments index characters outside the bounds of the value array. @since JDK1.1
Class String, int compareTo(Object)

Compares this String to another Object. If the Object is a String this function behaves like compareTo(String). Otherwise it throws a ClassCastException (as Strings are comparable only to other Strings). @param o the Object to be compared. @return the value 0 if the argument is a string lexicographically equal to this string; a value less than 0 if the argument is a string lexicographically greater than this string; and a value greater than 0 if the argument is a string lexicographically less than this string. @exception ClassCastException if the argument is not a String. @see java.lang.Comparable @since JDK11.2
Class String, int compareToIgnoreCase(String)

Compares two strings lexicographically ignoring case considerations. This method returns an integer whose sign is that of this.toUpperCase().toLowerCase().compareTo( str.toUpperCase().toLowerCase()).

Note that this method does not take locale into account and will result in an unsatisfactory ordering for certain locales. The java.text package provides collators to allow locale-sensitive ordering. @param str the String to be compared. @return a negative integer zero or a positive integer as the the specified String is greater than equal to or less than this String ignoring case considerations. @see java.text.Collator#compare(String String) @since JDK11.2

Class String, boolean equalsIgnoreCase(String)

Compares this String to another String ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

Two characters c1 and c2 are considered the same ignoring case if at least one of the following is true:

@param anotherString the String to compare this String against. @return true if the argument is not null and the Strings are equal ignoring case; false otherwise. @see #equals(Object) @see java.lang.Character#toLowerCase(char) @see java.lang.Character#toUpperCase(char)
Class String, byte[] getBytes(String)

Convert this String into bytes according to the specified character encoding storing the result into a new byte array. @param enc AThe name of a supported character-encoding nameencoding @return The resultant byte array @exception UnsupportedEncodingException If the named encoding is not supported @since JDK1.1
Class String, String toLowerCase()

Converts all of the characters in this String to lower case using the rules of the default locale which is returned by Locale.getDefault.

If no character in the string has a different lowercase version based on calling the toLowerCase method defined by Character then the original string is returned.

Otherwise this method creates a new String object that represents a character sequence identical in length to the character sequence represented by this String object with every character equal to the result of applying the method Character.toLowerCase to the corresponding character of this String object.

Examples:

 "French Fries".toLowerCase() returns "french fries" "".toLowerCase() returns "" 
@return the string converted to lowercase. @see java.lang.Character#toLowerCase(char) @see java.lang.String#toUpperCasetoLowerCase(Locale)
Class String, String toLowerCase(Locale)

Converts all of the characters in this String to lower case using the rules of the given Locale. Usually the characters are converted by calling Character.toLowerCase. Exceptions to this rule are listed in the following table:

Language Code of Locale Upper Case Lower Case Description
tr (Turkish) \u0130 \u0069 capital letter I with dot above -> small letter i
tr (Turkish) \u0049 \u0131 capital letter I -> small letter dotless i
@param locale use the case transformation rules for this locale @return the String converted to lowercase. @see java.lang.Character#toLowerCase(char) @see java.lang.String#toUpperCase(Locale) @since JDK1.1
Class String, String toUpperCase()

Converts all of the characters in this String to upper case using the rules of the default locale which is returned by Locale.getDefault.

If no character in this string has a different uppercase version based on calling the toUpperCase method defined by Character then the original string is returned.

Otherwise this method creates a new String object representing a character sequence identical in length to the character sequence represented by this String object and with every character equal to the result of applying the method Character.toUpperCase to the corresponding character of this String object.

Examples:

 "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN" "Visit Ljubinje ".toUpperCase() returns "VISIT LJUBINJE " 
@return the string converted to uppercase. @see java.lang.Character#toUpperCase(char) @see java.lang.String#toLowerCasetoUpperCase(Locale)
Class String, String toUpperCase(Locale)

Converts all of the characters in this String to upper case using the rules of the given locale. Usually the characters are converted by calling Character.toUpperCase. Exceptions to this rule are listed in the following table:

Language Code of Locale Lower Case Upper Case Description
tr (Turkish) \u0069 \u0130 small letter i -> capital letter I with dot above
tr (Turkish) \u0131 \u0049 small letter dotless i -> capital letter I
(all) \u00df \u0053 \u0053 small letter sharp s -> two letters: SS
@param locale use the case transformation rules for this locale @return the String converted to uppercase. @see java.lang.Character#toUpperCase(char) @see java.lang.String#toLowerCase(charLocale) @since JDK1.1
Class String, Comparator CASE_INSENSITIVE_ORDER

Returns a Comparator that orders String objects as by compareToIgnoreCase. This comparator is serializable.

Note that this Comparator does not take locale into account and will result in an unsatisfactory ordering for certain locales. The java.text package provides Collators to allow locale-sensitive ordering. @return Comparator for case insensitive comparison of strings @see java.text.Collator#compare(String String) @since JDK11.2


Class StringBuffer

A string buffer implements a mutable sequence of characters. A string buffer is like a String but can be modified. At any point in time it contains some particular sequence of characters but the length and content of the sequence can be changed through certain method calls.

String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.

String buffers are used by the compiler to implement the binary string concatenation operator +. For example the code:

 x = "a" + 4 + "c" 

is compiled to the equivalent of:

 x = new StringBuffer().append("a").append(4).append("c") .toString() 
which creates a new string buffer (initially empty) appends the string representation of each operand to the string buffer in turn and then converts the contents of the string buffer to a string. Overall this avoids creating many temporary strings.

The principal operations on a StringBuffer are the append and insert methods which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string buffer. The append method always adds these characters at the end of the buffer; the insert method adds the characters at a specified point.

For example if z refers to a string buffer object whose current contents are "start" then the method call z.append("le") would cause the string buffer to contain "startle" whereas z.insert(4 "le") would alter the string buffer to contain "starlet".

In general if sb refers to an instance of a StringBuffer then sb.append(x) has the same effect as sb.insert(sb.length()  x).

Every string buffer has a capacity. As long as the length of the character sequence contained in the string buffer does not exceed the capacity it is not necessary to allocate a new internal buffer array. If the internal buffer overflows it is automatically made larger. @author Arthur van Hoff @version 1.45 1062 04/2721/9800 @see java.io.ByteArrayOutputStream @see java.lang.String @since JDK1.0

Class StringBuffer, StringBuffer append(char)

Appends the string representation of the char argument to this string buffer.

The argument is appended to the contents of this string buffer. The length of this string buffer increases by 1.

The overall effect is exactly as if the argument were converted to a string by the method String#valueOf(char) and the character in that string were then appended to this StringBuffer object. @param chc a char. @return a reference to this StringBuffer object.

Class StringBuffer, StringBuffer delete(int, int)

Removes the characters in a substring of this StringBuffer. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the StringBuffer if no such character exists. If start is equal to end no changes are made. @param start The beginning index inclusive. @param end The ending index exclusive. @return This string buffer. @exception StringIndexOutOfBoundsException if start is negative greater than length() or greater than end. @since JDK11.2
Class StringBuffer, StringBuffer deleteCharAt(int)

Removes the character at the specified position in this StringBuffer (shortening the StringBuffer by one character). @param index Index of character to remove @return This string buffer. @exception StringIndexOutOfBoundsException if the index is negative or greater than or equal to length(). @since JDK11.2
Class StringBuffer, void getChars(int, int, char[], int)

Characters are copied from this string buffer into the destination character array dst. The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin. The characters are copied into the subarray of dst starting at index dstBegin and ending at index:

 dstbegin + (srcEnd-srcBegin) - 1 
@param srcBegin start copying at this offset in the string buffer. @param srcEnd stop copying at this offset in the string buffer. @param dst the array to copy the data into. @param dstBegin offset into dst. @exception NullPointerException if dst is null. @exception IndexOutOfBoundsException if any of the following is true:
Class StringBuffer, StringBuffer insert(int, Object)

Inserts the string representation of the Object argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param bobj an Object. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid. @see java.lang.String#valueOf(java.lang.Object) @see java.lang.StringBuffer#insert(int java.lang.String) @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer insert(int, char)

Inserts the string representation of the char argument into this string buffer.

The second argument is inserted into the contents of this string buffer at the position indicated by offset. The length of this string buffer increases by one.

The overall effect is exactly as if the argument were converted to a string by the method String#valueOf(char) and the character in that string were then String inserted} into this StringBuffer object at the position indicated by offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param chc a char. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsExceptionIndexOutOfBoundsException if the offset is invalid. @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer insert(int, char[])

Inserts the string representation of the char array argument into this string buffer.

The characters of the array argument are inserted into the contents of this string buffer at the position indicated by offset. The length of this string buffer increases by the length of the argument.

The overall effect is exactly as if the argument were converted to a string by the method String#valueOf(char[]) and the characters of that string were then String inserted} into this StringBuffer object at the position indicated by offset. @param offset the offset. @param chstr a character array. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid.

Class StringBuffer, StringBuffer insert(int, char[], int, int)

Inserts the string representation of a subarray of the str array argument into this string buffer. The subarray begins at the specified offset and extends len characters. The characters of the subarray are inserted into this string buffer at the position indicated by index. The length of this StringBuffer increases by len characters. @param index position at which to insert subarray. @param str A character array. @param offset the index of the first character in subarray to to be inserted. @param len the number of characters in the subarray to to be inserted. @return This string buffer. @exception StringIndexOutOfBoundsException if index is negative or greater than length() or offset or len are negative or (offset+len) is greater than str.length. @since JDK11.2
Class StringBuffer, StringBuffer insert(int, double)

Inserts the string representation of the double argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param bd a double. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid. @see java.lang.String#valueOf(double) @see java.lang.StringBuffer#insert(int java.lang.String) @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer insert(int, float)

Inserts the string representation of the float argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param bf a float. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid. @see java.lang.String#valueOf(float) @see java.lang.StringBuffer#insert(int java.lang.String) @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer insert(int, int)

Inserts the string representation of the second int argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf and the characters of that string are then inserted into this string buffer at the indicated offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param bi an int. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid. @see java.lang.String#valueOf(int) @see java.lang.StringBuffer#insert(int java.lang.String) @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer insert(int, long)

Inserts the string representation of the long argument into this string buffer.

The second argument is converted to a string as if by the method String.valueOf and the characters of that string are then inserted into this string buffer at the position indicated by offset.

The offset argument must be greater than or equal to 0 and less than or equal to the length of this string buffer. @param offset the offset. @param bl a long. @return a reference to this StringBuffer object. @exception StringIndexOutOfBoundsException if the offset is invalid. @see java.lang.String#valueOf(long) @see java.lang.StringBuffer#insert(int java.lang.String) @see java.lang.StringBuffer#length()

Class StringBuffer, StringBuffer replace(int, int, String)

Replaces the characters in a substring of this StringBuffer with characters in the specified String. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the StringBuffer if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start. (The StringBuffer will be lengthened to accommodate the specified String if necessary.) @param start The beginning index inclusive. @param end The ending index exclusive. @param str String that will replace previous contents. @return This string buffer. @exception StringIndexOutOfBoundsException if start is negative greater than length() or greater than end. @since JDK11.2
Class StringBuffer, String substring(int)

Returns a new String that contains a subsequence of characters currently contained in this StringBuffer.The substring begins at the specified index and extends to the end of the StringBuffer. @param start The beginning index inclusive. @return The new string. @exception StringIndexOutOfBoundsException if start is less than zero or greater than the length of this StringBuffer. @since JDK11.2
Class StringBuffer, String substring(int, int)

Returns a new String that contains a subsequence of characters currently contained in this StringBuffer. The substring begins at the specified start and extends to the character at index end - 1. An exception is thrown if @param start The beginning index inclusive. @param end The ending index exclusive. @return The new string. @exception StringIndexOutOfBoundsException if start or end are negative or greater than length() or start is greater than end. @since JDK11.2

Class StringIndexOutOfBoundsException

Thrown by the charAt method in class String and by other String methods to indicate that an index is either negative or greater than or equal to the size of the string. @author unascribed @version 1.16 0918 02/2102/9800 @see java.lang.String#charAt(int) @since JDK1.0

Class System

The System class contains several useful class fields and methods. It cannot be instantiated.

Among the facilities provided by the System class are standard input standard output and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array. @author Arthur van Hoff @version 1.100 03111 02/0802/00 @since JDK1.0

Class System, void arraycopy(Object, int, Object, int, int)

Copies an array from the specified source array beginning at the specified position to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dst. The number of components copied is equal to the length argument. The components at positions srcOffset through srcOffset+length-1 in the source array are copied into positions dstOffset through dstOffset+length-1 respectively of the destination array.

If the src and dst arguments refer to the same array object then the copying is performed as if the components at positions srcOffset through srcOffset+length-1 were first copied to a temporary array with length components and then the contents of the temporary array were copied into positions dstOffset through dstOffset+length-1 of the destination array.

If dst is null then a NullPointerException is thrown.

If src is null then a NullPointerException is thrown and the destination array is not modified.

Otherwise if any of the following is true an ArrayStoreException is thrown and the destination is not modified:

Otherwise if any of the following is true an IndexOutOfBoundsException is thrown and the destination is not modified:

Otherwise if any actual component of the source array from position srcOffset through srcOffset+length-1 cannot be converted to the component type of the destination array by assignment conversion an ArrayStoreException is thrown. In this case let k be the smallest nonnegative integer less than length such that src[srcOffset+k] cannot be converted to the component type of the destination array; when the exception is thrown source array components from positions srcOffset through srcOffset+k-1 will already have been copied to destination array positions dstOffset through dstOffset+k-1 and no other positions of the destination array will have been modified. (Because of the restrictions already itemized this paragraph effectively applies only to the situation where both arrays have component types that are reference types.) @param src: the source array. @param srcpossrc_position start position in the source array. @param destdst the destination array. @param destposdst_position pos start position in the destination data. @param length the number of array elements to be copied. @exception IndexOutOfBoundsException if copying would cause access of data outside array bounds. @exception ArrayStoreException if an element in the src array could not be stored into the dest array because of a type mismatch. @exception NullPointerException if either src or dst is null.

Class System, Properties getProperties()

Determines the current system properties.

First if there is a security manager its checkPropertiesAccess method is called with no arguments. This may result in a security exception.

The current set of system properties for use by the #getProperty(String) method is returned as a Properties object. If there is no current set of system properties a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:
Key Description of Associated Value
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory

Note that even if the security manager does not permit the getProperties operation it may choose to permit the #getProperty(String) operation. @return the system properties @exception SecurityException if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties. @see #setProperties @see java.lang.SecurityException @see java.lang.SecurityManager#checkPropertiesAccess() @see java.util.Properties

Class System, String getProperty(String)

Gets the system property indicated by the specified key.

First if there is a security manager its checkPropertyAccess method is called with the key as its argument. This may result in a SecurityException.

If there is no current set of system properties a set of system properties is first created and initialized in the same manner as for the getProperties method. @param key the name of the system property. @return the string value of the system property or null if there is no property with that key. @exception SecurityException if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property. @exception NullPointerException if key is null. @exception IllegalArgumentException if key is empty. @see #setProperty @see java.lang.SecurityException @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) @see java.lang.System#getProperties()

Class System, String getProperty(String, String)

Gets the system property indicated by the specified key.

First if there is a security manager its checkPropertyAccess method is called with the key as its argument.

If there is no current set of system properties a set of system properties is first created and initialized in the same manner as for the getProperties method. @param key the name of the system property. @param def a default value. @return the string value of the system property or the default value if there is no property with that key. @exception SecurityException if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property. @exception NullPointerException if key is null. @exception IllegalArgumentException if key is empty. @see #setProperty @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) @see java.lang.System#getProperties()

Class System, SecurityManager getSecurityManager()

Gets the system security interface. @return if a security manager has already been established for the current application then that security manager is returned; otherwise null is returned. @see #setSecurityManager
Class System, String getenv(String)

Gets an environment variable. An environment variable is a system-dependent external variable that has a string value. @deprecated The preferred way to extract system-dependent information is the system properties of the java.lang.System.getProperty methods and the corresponding getTypeName methods of the Boolean Integer and Long primitive types. For example:
 String classPath = System.getProperty("java.class.path" "."); 
if (Boolean.getBoolean("myapp.exper.mode")) enableExpertCommands();
@param the name of the environment variable. @return the value of the variable or null if the variable is not defined. @see java.lang.Boolean#getBoolean(java.lang.String) @see java.lang.Integer#getInteger(java.lang.String) @see java.lang.Integer#getInteger(java.lang.String int) @see java.lang.Integer#getInteger(java.lang.String java.lang.Integer) @see java.lang.Long#getLong(java.lang.String) @see java.lang.Long#getLong(java.lang.String long) @see java.lang.Long#getLong(java.lang.String java.lang.Long) @see java.lang.System#getProperties() @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Class System, int identityHashCode(Object)

Returns the same hashcode for the given object as would be returned by the default method hashCode() whether or not the given object's class overrides hashCode(). The hashcode for the null reference is zero. @param x object for which the hashCode is to be calculated @return the hashCode @since JDK1.1
Class System, String mapLibraryName(String)

Maps a library name into a platform-specific string representing a native library. @param libname the name of the library. @return a platform-dependent native library name. @see java.lang.System#loadLibrary(java.lang.String) @see java.lang.ClassLoader#findLibrary(java.lang.String) @since JDK11.2
Class System, void runFinalizersOnExit(boolean)

Enable or disable finalization on exit; doing so specifies that the finalizers of all objects that have finalizers that have not yet been automatically invoked are to be run before the Java runtime exits. By default finalization on exit is disabled.

If there is a security manager its checkExit method is first called with 0 as its argument to ensure the exit is allowed. This could result in a SecurityException. @deprecated This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects resulting in erratic behavior or deadlock. @param value indicating enabling or disabling of finalization @throws SecurityException if a security manager exists and its checkExit method doesn't allow the exit. @see java.lang.Runtime#exit(int) @see java.lang.Runtime#gc() @see java.lang.SecurityManager#checkExit(int) @since JDK1.1

Class System, void setErr(PrintStream)

Reassigns the "standard" error output stream.

First if there is a security manager its checkPermission method is called with a RuntimePermission("setIO") permission to see if it's ok to reassign the "standard" error output stream. @param outerr the new standard error output stream. @throws SecurityException if a security manager exists and its checkPermission method doesn't allow reassigning of the standard error output stream. @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK1.1

Class System, void setOut(PrintStream)

Reassigns the "standard" output stream.

First if there is a security manager its checkPermission method is called with a RuntimePermission("setIO") permission to see if it's ok to reassign the "standard" output stream. @param out the new standard output stream. @throws SecurityException if a security manager exists and its checkPermission method doesn't allow reassigning of the standard output stream. @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK1.1

Class System, void setProperties(Properties)

Sets the system properties to the Properties argument.

First if there is a security manager its checkPropertiesAccess method is called with no arguments. This may result in a security exception.

The argument becomes the current set of system properties for use by the #getProperty(String) method. If the argument is null then the current set of system properties is forgotten. @param props the new system properties. @exception SecurityException if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties. @see #getProperties @see java.langutil.Properties @see java.lang.SecurityException @see java.lang.SecurityManager#checkPropertiesAccess()

Class System, String setProperty(String, String)

Sets the system property indicated by the specified key.

First if a security manager exists its SecurityManager.checkPermission method is called with a PropertyPermission(key "write") permission. This may result in a SecurityException being thrown. If no exception is thrown the specified property is set to the given value.

@param key the name of the system property. @param value the value of the system property. @return the previous value of the system property or null if it did not have one. @exception SecurityException if a security manager exists and its checkPermission method doesn't allow setting of the specified property. @exception NullPointerException if key is null. @exception IllegalArgumentException if key is empty. @see #getProperty @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.util.PropertyPermission @see SecurityManager#checkPermission @since JDK11.2

Class System, void setSecurityManager(SecurityManager)

Sets the System security.

If there is a security manager already installed this method first calls the security manager's checkPermission method with a RuntimePermission("setSecurityManager") permission to ensure it's ok to replace the existing security manager. This may result in throwing a SecurityException.

Otherwise the argument is established as the current security manager. If the argument is null and no security manager has been established then no action is taken and the method simply returns. @param s the security manager. @exception SecurityException if the security manager has already been set and its checkPermission method doesn't allow it to be replaced. @see #getSecurityManager @see SecurityManager#checkPermission @see java.lang.RuntimePermission


Class Thread

A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.

Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new Thread object the new thread has its priority initially set equal to the priority of the creating thread and is a daemon thread if and only if the creating thread is a daemon.

When a Java Virtual Machine starts up there is usually a single non-daemon thread (which typically calls the method named main of some designated class). The Java Virtual Machine continues to execute threads until either of the following occurs:

There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started. For example a thread that computes primes larger than a stated value could be written as follows:


 class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime  . . . } } 

The following code would then create a thread and start it running:

 PrimeThread p = new PrimeThread(143); p.start(); 

The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated passed as an argument when creating Thread and started. The same example in this other style looks like the following:


 class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime  . . . } } 

The following code would then create a thread and start it running:

 PrimeRun p = new PrimeRun(143); new Thread(p).start(); 

Every thread has a name for identification purposes. More than one thread may have the same name. If a name is not specified when a thread is created a new name is generated for it. @author unascribed @version 1.97 11106 02/0502/9800 @see java.lang.Runnable @see java.lang.Runtime#exit(int) @see java.lang.Thread#run() @see java.lang.Thread#stop() @since JDK1.0

Class Thread, void checkAccess()

Determines if the currently running thread has permission to modify this thread.

If there is a security manager its checkAccess method is called with this thread as its argument. This may result in throwing a SecurityException.

Note: This method was mistakenly non-final in JDK 1.1. It has been made final in JDKthe 1.Java 2 Platform. @exception SecurityException if the current thread is not allowed to access this thread. @see java.lang.SecurityManager#checkAccess(java.lang.Thread)

Class Thread, int enumerate(Thread[])

Copies into the specified array every active thread in this thread's thread group and its subgroups. This method simply calls the enumerate method of this thread's thread group with the array argument.

First if there is a security manager that enumerate method calls the security manager's checkAccess method with the thread group as its argument. This may result in throwing a SecurityException. @param tarray an array of Thread objects to copy to @return the number of threads put into the array. @exception SecurityException if a security manager exists and its checkAccess method doesn't allow the operation. @see java.lang.ThreadGroup#enumerate(java.lang.Thread[]) @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)

Class Thread, ClassLoader getContextClassLoader()

Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources. If not set the default is the ClassLoader context of the parent Thread. The context ClassLoader of the primordial thread is typically set to the class loader used to load the application.

First if there is a security manager and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the context class loader for the thread whose context class loader is being requested then the security manager's checkPermission method is called with a RuntimePermission("getClassLoader") permission to see if it's ok to get the context ClassLoader.. @return the context ClassLoader for this Thread @throws SecurityException if a security manager exists and its checkPermission method doesn't allow getting the context ClassLoader. @see #setContextClassLoader @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK11.2

Class Thread, String getName()

Returns this thread's name. @return this thread's name. @see #setName @see java.lang.Thread#setName(java.lang.String)
Class Thread, int getPriority()

Returns this thread's priority. @return this thread's name. @see #setPriority @see java.lang.Thread#setPriority(int)
Class Thread, void resume()

Resumes a suspended thread.

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException (in the current thread).

If the thread is alive but suspended it is resumed and is permitted to make progress in its execution. @exception SecurityException if the current thread cannot modify this thread. @see #checkAccess @see java.lang.Thread#suspend() @deprecated This method exists solely for use with #suspend which has been deprecated because it is deadlock-prone. For more information see Why are Thread.stop Thread.suspend and Thread.resume Deprecated .

Class Thread, void setContextClassLoader(ClassLoader)

Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is created and allows the creator of the thread to provide the appropriate class loader to code running in the thread when loading classes and resources.

First if there is a security manager its checkPermission method is called with a RuntimePermission("setContextClassLoader") permission to see if it's ok to set the context ClassLoader.. @param cl the context ClassLoader for this Thread @exception SecurityException if the current thread cannot set the context ClassLoader. @see #getContextClassLoader @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since JDK11.2

Class Thread, void setName(String)

Changes the name of this thread to be equal to the argument name.

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException. @param name the new name for this thread. @exception SecurityException if the current thread cannot modify this thread. @see #getName @see java.lang.Thread#checkAccess() @see java.lang.Thread#getName()

Class Thread, void setPriority(int)

Changes the priority of this thread.

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException.

Otherwise the priority of this thread is set to the smaller of the specified newPriority and the maximum permitted priority of the thread's thread group. @param newPriority priority to set this thread to @exception IllegalArgumentException If the priority is not in the range MIN_PRIORITY to MAX_PRIORITY. @exception SecurityException if the current thread cannot modify this thread. @see #getPriority @see java.lang.Thread#checkAccess() @see java.lang.Thread#getPriority() @see java.lang.Thread#getThreadGroup() @see java.lang.Thread#MAX_PRIORITY @see java.lang.Thread#MIN_PRIORITY @see java.lang.ThreadGroup#getMaxPriority()

Class Thread, void stop()

Forces the thread to stop executing.

If there is a security manager installed its checkAccess method is called with this as its argument. This may result in a SecurityException being raised (in the current thread).

If this thread is different from the current thread (that is the current thread is trying to stop a thread other than itself) the security manager's checkPermission method (with a RuntimePermission("stopThread") argument) is called in addition. Again this may result in throwing a SecurityException (in the current thread).

The thread represented by this thread is forced to stop whatever it is doing abnormally and to throw a newly created ThreadDeath object as an exception.

It is permitted to stop a thread that has not yet been started. If the thread is eventually started it immediately terminates.

An application should not normally try to catch ThreadDeath unless it must do some extraordinary cleanup operation (note that the throwing of ThreadDeath causes finally clauses of try statements to be executed before the thread officially dies). If a catch clause catches a ThreadDeath object it is important to rethrow the object so that the thread actually dies.

The top-level error handler that reacts to otherwise uncaught exceptions does not print out a message or otherwise notify the application if the uncaught exception is an instance of ThreadDeath. @exception SecurityException if the current thread cannot modify this thread. @see java.lang.Thread#interrupt() @see java.lang.Thread#checkAccess() @see java.lang.Thread#run() @see java.lang.Thread#start() @see java.lang.ThreadDeath @see java.lang.ThreadGroup#uncaughtException(java.lang.Thread java.lang.Throwable) @see SecurityManager#checkAccess(Thread) @see SecurityManager#checkPermission @deprecated This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state the damaged objects become visible to other threads potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable for example) the interrupt method should be used to interrupt the wait. For more information see Why are Thread.stop Thread.suspend and Thread.resume Deprecated .

Class Thread, void stop(Throwable)

Forces the thread to stop executing.

If there is a security manager installed the checkAccess method of this thread is called which may result in a SecurityException being raised (in the current thread).

If this thread is different from the current thread (that is the current thread is trying to stop a thread other than itself) or obj is not an instance of ThreadDeath the security manager's checkPermission method (with the RuntimePermission("stopThread") argument) is called in addition. Again this may result in throwing a SecurityException (in the current thread).

If the argument obj is null a NullPointerException is thrown (in the current thread).

The thread represented by this thread is forced to complete whatever it is doing abnormally and to throw the Throwable object obj as an exception. This is an unusual action to take; normally the stop method that takes no arguments should be used.

It is permitted to stop a thread that has not yet been started. If the thread is eventually started it immediately terminates. @param obj the Throwable object to be thrown. @exception SecurityException if the current thread cannot modify this thread. @see java.lang.Thread#interrupt() @see java.lang.Thread#checkAccess() @see java.lang.Thread#run() @see java.lang.Thread#start() @see java.lang.Thread#stop() @see SecurityManager#checkAccess(Thread) @see SecurityManager#checkPermission @deprecated This method is inherently unsafe. See #stop (with no arguments) for details. An additional danger of this method is that it may be used to generate exceptions that the target thread is unprepared to handle (including checked exceptions that the thread could not possibly throw were it not for this method). For more information see Why are Thread.stop Thread.suspend and Thread.resume Deprecated .

Class Thread, void suspend()

Suspends this thread.

First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException (in the current thread).

If the thread is alive it is suspended and makes no further progress unless and until it is resumed. @exception SecurityException if the current thread cannot modify this thread. @see #checkAccess @deprecated This method has been deprecated as it is inherently deadlock-prone. If the target thread holds a lock on the monitor protecting a critical system resource when it is suspended no thread can access this resource until the target thread is resumed. If the thread that would resume the target thread attempts to lock this monitor prior to calling resume deadlock results. Such deadlocks typically manifest themselves as "frozen" processes. For more information see Why are Thread.stop Thread.suspend and Thread.resume Deprecated .


Class ThreadDeath

An instance of ThreadDeath is thrown in the victim thread when the stop method with zero arguments in class Thread is called.

An application should catch instances of this class only if it must clean up after being terminated asynchronously. If ThreadDeath is caught by a method it is important that it be rethrown so that the thread actually dies.

The top-level error handler does not print out a message if ThreadDeath is never caught.

The class ThreadDeath is specifically a subclass of Error rather than Exception even though it is a "normal occurrence" because many applications catch all occurrences of Exception and then discard the exception. @author unascribed @version 1.10 0912 02/2102/9800 @see java.lang.Thread#stop() @since JDK1.0


Class ThreadGroup

A thread group represents a set of threads. In addition a thread group can also include other thread groups. The thread groups form a tree in which every thread group except the initial thread group has a parent.

A thread is allowed to access information about its own thread group but not to access information about its thread group's parent thread group or any other thread groups. @author unascribed @version 1.45 0451 02/2202/9900 @since JDK1.0

Class ThreadGroup, boolean allowThreadSuspension(boolean)

Used by VM to control lowmem implicit suspension. @param b boolean to allow or disallow suspension @return true on success @since JDK1.1 @deprecated The definition of this call depends on #suspend which is deprecated. Further the behavior of this call was never specified.
Class ThreadGroup, int getMaxPriority()

Returns the maximum priority of this thread group. Threads that are part of this group cannot have a higher priority than the maximum priority. @return the maximum priority that a thread in this thread group can have. @see #setMaxPriority @since JDK1.0
Class ThreadGroup, ThreadGroup getParent()

Returns the parent of this thread group.

First if the parent is not null the checkAccess method of the parent thread group is called with no arguments; this may result in a security exception. @return the parent of this thread group. The top-level thread group is the only thread group whose parent is null. @exception SecurityException if the current thread cannot accessmodify the parentthis thread group. @see java.lang.ThreadGroup#checkAccess() @see java.lang.SecurityException @see java.lang.RuntimePermission @since JDK1.0

Class ThreadGroup, void interrupt()

Interrupts all threads in this thread group.

First the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

This method then calls the interrupt method on all the threads in this thread group and in all of its subgroups. @exception SecurityException if the current thread is not allowed to access this thread group or any of the threads in the thread group. @see java.lang.Thread#interrupt() @see java.lang.SecurityException @see java.lang.ThreadGroup#checkAccess() @since JDK11.2

Class ThreadGroup, boolean isDestroyed()

Tests if this thread group has been destroyed. @return true if this object is destroyed @since JDK1.1
Class ThreadGroup, void setMaxPriority(int)

Sets the maximum priority of the group.

First the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

Threads in the thread group that already have a higher priority are not affected. @param pri the new priority of the thread group. @exception SecurityException if the current thread cannot modify this thread group. @see #getMaxPriority @see java.lang.SecurityException @see java.lang.ThreadGroup#checkAccess() @since JDK1.0


Class ThreadLocal

This class provides ThreadLocal variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own independently initialized copy of the variable. ThreadLocal objects are typically private static variables in classes that wish to associate state with a thread (e.g. a user ID or Transaction ID).

Each thread holds an implicit reference to its copy of a ThreadLocal as long as the thread is alive and the ThreadLocal object is accessible; after a thread goes away all of its copies of ThreadLocal variables are subject to garbage collection (unless other references to these copies exist). @author Josh Bloch @version 1.8 0716 02/0802/9800 @since JDK11.2

Class ThreadLocal, Object get()

Returns the value in the calling thread's copy of this ThreadLocal variable. Creates and initializes the copy if this is the first time the thread has called this method. @return the value of this ThreadLocal
Class ThreadLocal, Object initialValue()

Returns the calling thread's initial value for this ThreadLocal variable. This method will be called once per accessing thread for each ThreadLocal the first time each thread accesses the variable with get or set. If the programmer desires ThreadLocal variables to be initialized to some value other than null ThreadLocal must be subclassed and this method overridden. Typically an anonymous inner class will be used. Typical implementations of initialValue will call an appropriate constructor and return the newly constructed object. @return the initial value for this ThreadLocal

Class Throwable

The Throwable class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (or of one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement. Similarly only this class or one of its subclasses can be the argument type in a catch clause.

Instances of two subclasses java.lang.Error and java.lang.Exception are conventionally used to indicate that exceptional situations have occurred. Typically these instances are freshly created in the context of the exceptional situation so as to include relevant information (such as stack trace data).

By convention class Throwable and its subclasses have two constructors one that takes no arguments and one that takes a String argument that can be used to produce an error message.

A Throwable class contains a snapshot of the execution stack of its thread at the time it was created. It can also contain a message string that gives more information about the error.

Here is one example of catching an exception:

 try { int a[] = new int[2]; a[4]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("exception: " + e.getMessage()); e.printStackTrace(); } 
@author unascribed @version 1.31 0144 02/2602/9700 @since JDK1.0
Class Throwable, constructor Throwable(String)

Constructs a new Throwable with the specified error message. Also the method @#fillInStackTrace() is called for this object. @param message the error message. The error message is saved for later retrieval by the @#getMessage() method.
Class Throwable, Throwable fillInStackTrace()

Fills in the execution stack trace. This method records within this Throwable object information about the current state of the stack frames for the current thread. This method is useful when an application is re-throwing an error or exception. For example:

 try { a = b / c; } catch(ArithmeticThrowable e) { a = NumberDouble.MAX_VALUE; throw e.fillInStackTrace(); } 
@return this Throwable object. @see java.lang.Throwable#printStackTrace()
Class Throwable, String getLocalizedMessage()

Creates a localized description of this Throwable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method the default implementation returns the same result as getMessage(). @return The localized description of this Throwable. @since JDK1.1
Class Throwable, String getMessage()

Returns the errorterror message string of this throwable object. @return the error message string of this Throwable object if it was created with an error message string; or null if it was created with no error message.
Class Throwable, void printStackTrace(PrintStream)

Prints this Throwable and its backtrace to the specified print stream. @param s PrintStream to use for output
Class Throwable, void printStackTrace(PrintWriter)

Prints this Throwable and its backtrace to the specified print writer. @param s PrintWriter to use for output @since JDK1.1

Class UnknownError

Thrown when an unknown but serious exception has occurred in the Java Virtual Machine. @author unascribed @version 1.8 0910 02/2102/9800 @since JDK1.0

Class UnsatisfiedLinkError

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native. @author unascribed @version 1.16 0918 02/2102/9800 @see java.lang.Runtime @since JDK1.0

Class UnsupportedClassVersionError

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported. @since JDK11.2

Class UnsupportedOperationException

Thrown to indicate that the requested operation is not supported. @author Josh Bloch @version 1.7 0912 02/2102/9800 @since JDK11.2
Class UnsupportedOperationException, constructor UnsupportedOperationException(String)

Constructs an UnsupportedOperationException with the specified detail message. @param message the detail message

Class VerifyError

Thrown when the "verifier" detects that a class file though well formed contains some sort of internal inconsistency or security problem. @author unascribed @version 1.8 0910 02/2102/9800 @since JDK1.0

Class VirtualMachineError

Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating. @author Frank Yellin @version 1.9 0911 02/2102/9800 @since JDK1.0

Class Void

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void. @author unascribed @version 1.6 098 02/2102/9800 @since JDK1.1