Chapter 13

The Java Language Package

by Debasis Samanta


CONTENTS

Introduction

The Java Language Package java.lang provides 21 classes, 2 interfaces, 21 classes for exceptions, and 19 classes for errors; it forms the core of the Java language and the JVM. This is the only package that is automatically imported into every Java program. Following are the list of classes, interfaces, classes of exceptions, and classes of errors :

Classes     
                     
Class Boolean 		    
Class Character 
Class Class 
Class ClassLoader 
Class Compiler 
Class Double 
Class Float 
Class Integer 
Class Long 
Class Math 
Class Number 
Class Object 
Class Process 
Class Runtime 
Class SecurityManager 
Class String 
Class StringBuffer 
Class System 
Class Thread 
Class ThreadGroup 
Class Throwable 

Exceptions

Class ArithmeticException 
Class ArrayIndexOutOfBoundsException 
Class ArrayStoreException 
Class ClassCastException 
Class ClassNotFoundException 
Class CloneNotSupportedException 
Class Exception 
Class IllegalAccessException 
Class IllegalArgumentException 
Class IllegalMonitorStateException 
Class IllegalThreadStateException 
Class IndexOutOfBoundsException 
Class InstantiationException 
Class InterruptedException 
Class NegativeArraySizeException 
Class NoSuchMethodException 
Class NullPointerException 
Class NumberFormatException 
Class RuntimeException 
Class SecurityException 
Class StringIndexOutOfBoundsException

Errors

Class AbstractMethodError 
Class ClassCircularityError 
Class ClassFormatError 
Class Error 
Class IllegalAccessError 
Class IncompatibleClassChangeError 
Class InstantiationError 
Class InternalError 
Class LinkageError 
Class NoClassDefFoundError 
Class NoSuchFieldError 
Class NoSuchMethodError 
Class OutOfMemoryError 
Class StackOverflowError 
Class ThreadDeath 
Class UnknownError 
Class UnsatisfiedLinkError 
Class VerifyError 
Class VirtualMachineError

Interfaces

Interface Cloneable 
Interface Runnable

Class Boolean

This class provides us to define primitive type boolean for an object. An object of type Boolean contains a single field whose type is boolean. In addition, this class provides a number of 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. The various component in this class is stated below :

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

       	// 	Constructors
		public Boolean(boolean  value);	
		//	Creates  a Boolean object initialized with the value argument.
		public Boolean(String  s);
		/*	Creates a Boolean object initialized with the value true if the string argument is not null and is equal, ignoring case, to the string "true". Otherwise, creates a Boolean object initialized with the value false. */
		// Methods
		public boolean booleanValue();	
		public boolean equals(Object  obj);	
		public static boolean  getBoolean(String  name);	
		public int hashCode();	
		public String toString();	
		public static Boolean valueOf(String  s);	
    }
The performance of various methods in the class Boolean are listed in Table 2.1 :

Table 2.1


Methods


Description

booleanValue()

Returns : The primitive boolean value of this object.

equals(Object obj)

The result is true if and only if the argument is not null and is a Boolean object that contains the same boolean value as this object.Returns : True if the objects are the same; false otherwise.

getBoolean(String name)

The result is true if and only if the system property named by the argument exists and is equal, ignoring case to the string “true”.

hashCode()

Returns : a hash code value for this object.

toString()

If this object contains the value true, a string equal to "true" is returned. Otherwise, a string equal to "false" is returned.

valueOf(String s)

A new Boolean object is constructed. This Boolean contains the value true if the string argument is not null and is equal, ignoring case, to the string "true".Returns : the Boolean value represented by the string.

Class Character

This class provides us 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 a number of 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 Unicode attribute table is available on the World Wide Web as the file :

ftp ://unicode.org/pub/MappingTables/UnicodeData1.1.5.txt
The various component in this class is stated as below :
	public  final  class  java.lang.Character extends  java.lang.Object    	    {
			// 		Member elements
			public final static int MAX_RADIX;	
			/*	The constant value of this field is the largest value ( say, 36) permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer. 
			*/
			public final static char MAX_VALUE;	
			//	The constant value of this field is the largest value (e.g. '\uffff' of type char.

			public final static int MIN_RADIX;
			/*	The constant value of this field is the smallest value ( say, 2) permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer. 
			*/ 	
			public final static char MIN_VALUE;
			//	The constant value of this field is the smallest value (e.g. '\u0000' of type char.)

				 // Constructor
			public Character(char  value);	
			//	Creates a Character object and initializes it so that it represents the value argument.

			// 		Methods
			public char charValue();	
			public static int digit(char  ch, int  radix);	
			public boolean equals(Object  obj);	
			public static char forDigit(int  digit, int  radix);	
			public int hashCode();	
			public static boolean isDefined(char  ch);	
			public static boolean isDigit(char  ch);	
			public static boolean isJavaLetter(char  ch);	
			public static boolean isJavaLetterOrDigit(char  ch);	
			public static boolean isLetter(char  ch);	
			public static boolean isLetterOrDigit(char  ch);	
			public static boolean isLowerCase(char  ch);	
			public static boolean isSpace(char  ch);	
			public static boolean isTitleCase(char  ch);	
			public static boolean isUpperCase(char  ch);
			public static char toLowerCase(char  ch);	
			public String toString();	
			public static char toTitleCase(char  ch);	
			public static char toUpperCase(char  ch);	
	    }
	The function of various methods are listed in Table 2.2.

Table 2.2

 

Method

Description

charValue()

Returns :the char value represented by this object.

digit(char ch, int radix)

Returns the numeric value of the character ch in the specified radix.

If the radix is not in the range MIN_RADIX <= RADIX <= MAX_RADIX or if the ch is not a valid digit in the specified radix, -1 is returned. A character is a valid digit if either of the following is true :

The method isDigit is true, and the Unicode decimal digit value of the character (or its single-character decomposition) is less than the specified radix. The character is one of the uppercase Latin letters 'A' through 'Z' and its code is less than radix +’A’-10. The character is one of the lowercase Latin letters 'a' through 'z' and its code is less that radix +’A’-10. In this case, ch - ‘A’ + 10 is returned.

equals(Object obj)

The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.

Returns : true if the objects are the same; false otherwise.

forDigit(int digit, int radix)

Determines the character representation for a specific digit in the specified radix. If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character ('\u0000') is returned.

The radix argument is valid if it is greater than or equal to MIN_RADIX and less than or equal to MAX_RADIX. The digit atgument is valid if 0 <= digit <= radix. If the digit is less than 10, then ‘0’ + digit is returned. Otherwise, the value ‘a’ + digit - 10 is returned.

.

hashCode()

Returns : a hash code value for this object.

isDefined(char ch)

Determines if a character has a defined meaning in Unicode. A character is defined if at least one of the following is true :

It has an entry in the Unicode attribute table.

Its value is in the range ‘\u3040’ <= ch <= ‘\u9FA5’

Its value is in the range ‘\uF900’ <= ch <= ‘\uFA2’

Returns : true if the character has a defined meaning in Unicode; false otherwise.

isDigit(char ch)

Returns : true if the character has a defined meaning in Unicode; false otherwise.

isJavaLetter(char ch)

Determines whether the specified character is a "Java" letter, that is, the character is permissible as the first character in an identifier in the Java language. A character is considered to be a Java letter if and only if it is a letter, the ASCII dollar sign character '$', or the underscore character '_'.

Returns : true if the character is a Java letter; false otherwise.

isJavaLetterOrDigit(char ch)

Determines whether the specified character is a "Java" letter or digit, that is, the character is permissible as a non-initial character in an identifier in the Java language. A character is considered to be a Java letter or digit if and only if it is a letter, a digit, the ASCII dollar sign character '$', or the underscore character '_'. Returns :true if the character is a Java letter or digit; false otherwise.

isLetter(char ch)

Determines whether the specified character is a letter. Returns : true if the character is a letter; false otherwise.

isLetterOrDigit(char ch)

Returns : true, if the character is a letter or digit; false otherwise.

isLowerCase(char ch)

Determines whether the specified character is a lowercase character. A character is lowercase if it is not in the range '\u2000' through '\u2FFF.,Returns : true if the character is lowercase; false otherwise.

isSpace(char ch)

Determines if the character ch is wihite space. This method returns true for the following five characters only :

`\t`\u0009 HORIZONTAL TABULATION

`\n` \u000A NEW LINE

`\f` \u000C FORM FEED

`\r` \u000D CARRIAGE RETURN

`` \u0020 SPACE

isTitleCase(char ch)

Determines if the character is a titlecase character.There are four Unicode characters whose printed representations look like pairs of Latin letters. For example, there is an uppercase letter that looks like "LJ" and the corresponding lowercase letter looks like "lj". A third form, which looks like "Lj" that is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title..


isUpperCase(char ch)

Determines whether the specified character is an uppercase character. A character is uppercase if it is not in the range '\u2000' through '\u2FFF'.

Returns : true, if the character is uppercase; false otherwise.

toLowerCase(char ch)

The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned. A character has a lowercase equivalent if and only if a lowercase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '\u2000' through '\u2FFF' have lowercase mappings; this method does map such characters to their lowercase equivalents even though the method isUpperCase does not return true for such characters.

toString()

Converts this Character object to a string. The result is a string whose length is 1 and whose sole component is the primitive char value represented by this object..

toTitleCase(char ch)

Converts the character argument to titlecase. A character has a titlecase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '\u2000' through '\u2FFF' have titlecase mappings; this method does map such characters to their titlecase equivalents even though the method isTitleCase does not return true for such characters.

toUpperCase(char ch)

Converts the character argument to uppercase. A character has an uppercase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.

Returns : The uppercase equivalent of the character, if any; otherwise the character itself.

Class Class

Instances of the class Class represent classes and interfaces in running a Java application. There is no member elements and public constructor for the class Class. Class objects are constructed automatically by the JVM as classes are loaded and or by calls to the defineClass method in the class ClassLoader. The structure of this class is given below :

	
	public  final  class  java.lang.Class
    				extends  java.lang.Object  
	  {
        		// Methods
    	public static Class forName(String  className);	
    	public ClassLoader getClassLoader();	
    	public Class[] getInterfaces();	
    	public String getName();	
    	public Class getSuperclass();	
    	public boolean isInterface();	
    	public Object newInstance();	
    	public String toString();	
	  }
The operation performed by the various methods in it are tabulated in Table 2.3.
	  
Table 2.3

 

Method

Description

forName(String className)

Returns the Class object associated with the class with the given string name.

For example, the following code fragment returns the runtime Class descriptor for the class named java.lang.Thread :

Class t = Class.forName("java.lang.Thread")

Throws : ClassNotFoundException, if the class could not be found.

getClassLoader()

Determines the class loader.

Returns : The class loader that created the class or interface represented by this object, or null if the class was not created by a class loader.

getInterfaces()

Determines the interfaces implemented by the class or interface represented by this object. If this object represents a class, the return value is an array containing objects representing all interfaces implemented by the class. The order of the interface objects in the array corresponds to the order of the interface names in the implements clause of the declaration of the class represented by this object. If this object represents an interface, the array contains objects representing all interfaces extended by the interface. The order of the interface objects in the array corresponds to the order of the interface names in the extends clause of the declaration of the interface represented by this object. If the class or interface implements no interfaces, the method returns an array of length 0.

Returns :an array of interfaces implemented by this class.

getName()

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

getSuperclass()

If this object represents any class other than the class Object, then the object that represents the superclass of that class is returned. If this object is the one that represents the class Object or this object represents an interface, null is returned.

isInterface()

Returns : true if this object represents an interface; false otherwise.

newInstance()

Creates a new instance of a class. Returns : a newly allocated instance of the class represented by this object. This is done exactly as if by a new expression with an empty argument list.

Throws : InstantiationException, If an application tries to instantiate an abstract class or an interface, or if the instantiation fails for some other reason. It also throws IllegalAccessException, If the class or initializer is not accessible.

toString()

Converts the object to a string. The string representation is the string "class" or "interface" followed by a space and then the fully qualified name of the class.

Class ClassLoader

The class ClassLoader is an abstract class. Applications implement subclasses of ClassLoader in order to extend the manner in which the JVM dynamically loads classes. Normally, the JVM 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 convets 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 ClassLoader may reference other classes. To determine the class(es) referred to, the Java Virtual Machine calls the loadClass method of the class loader that oroginally created the class. If the JVM only needs to determine if the class exist and if it does exist to know its superclass, the resolve flag is set to false. However, if an instance of the class is being craeted or any of its method is being called, the class must also be resolved. In this case, the resolve flag is set to true, and the resolveClass method should called. The class body is described as below :

	public  abstract class  java.lang.ClassLoader
    					extends  java.lang.Object
	{
        	// 	Constructors
    	protected ClassLoader();	
		/* 	Creates a new class loader and initializes it. If there is a security manager, its checkCreateClassLoader method is called. It may result in a security exception, if the current thread does not have permission to create a new class loader.
		*/

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


	Operation performed by the various methods in this class is listed in Table 2.4.

Table 2.4

 

Method

Description

defineClass(byte data[], int offset, int length)

Converts an array of bytes into an instance of class Class.

Returns : The class object which was created from the data.

Throws : ClassFormatError, if the data does not contain a valid Class.

findSystemClass(String name)

Finds the system class with the specified name, loading it in if necessary. A system class is a class loaded from the local file system in a platform- dependent way. It has no class loader.

loadClass(String name, boolean resolve)

Requests the class loader to load a class with the specified name. The loadClass method is called by the Java Virtual Machine when a class loaded by a class loader first references another class. Every subclass of class ClassLoader must define this method. If the resolve flag is true, the method should call the resolveClass method on the resulting class object. Class loaders should use a hash table or other cache to avoid defining classes with the same name multiple times.

Returns : the resulting Class, or null if it was not found.

Throws : ClassNotFoundException, if the ClassLoader cannot find a definition for the class.

resolveClass(Class c)

Resolves the class so that an instance of the class can be created, or so that one of its methods can be called. This method should be called by loadClass if the resolve flag is true.

Class Compiler

The class Compiler is provided in support of Java-to-native-code compilers and related services. When the JVM first starts, it determines if a system property java.compiler exists. If so, it is assumed to be the name of a library (whose exact location and type is platform-dependent); the loadLibrary method in class System is called to load that library. If this loading suceeds, the function named java.lang.Compiler.start() in that library is called. In case, if there is no compiler available, these methods do nothing.

	
	The body of this class is here under.
	public  final  class  java.lang.Compiler
    					extends  java.lang.Object  
	{
        	// 	Methods
    	public static Object command(Object  any);	
   	public static boolean compileClass(Class  clazz);	
    	public static boolean compileClasses(String  string);	
    	public static void disable();	
    	public static void enable();	
	}
	Methode are described in Table 2.5.

Table 2.5

Method

Description

command(Object any)

The Compiler should examine the argument type and its fields and perform some documented operation. No specific operations are required.

Returns : a compiler-specific value, or null if no compiler is available.

compileClass(Class clazz)

The indicated class is compiled.

Returns : true if the compilation succeeded; false if the compilation failed or no compiler is available.

compileClasses(String string)

Indicates that the application would like the third-party software to compile all classes whose name matches the indicated string.

Returns : true if the compilation succeeded; false if the compilation failed or no compiler is available.

disable()

Cause the Compiler to cease operation.

enable()

Cause the Compiler to resume operation.

Class Double

This 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 a number of 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. The various components in this class is listed as below :

	
		public  final  class  java.lang.Double
							extends  java.lang.Number
			{
				// 	Member elements
			public final static double MAX_VALUE;
			//	MAX_VALUE = 1.79769313486231570e+308d, The largest positive value of type double. 
			public final static double MIN_VALUE;
			//	MIN_VALUE = 4.94065645841246544e-324, The smallest positive finite value of type double.	
			public final static double NaN;
			//	NaN = 0.0 / 0.0 , a Not-a-Number value of type double.
			public final static double NEGATIVE_INFINITY;	
			//	NaN = 0.0 / 0.0 , a  Not-a-Number value of type double.
			public final static double POSITIVE_INFINITY;
			//	POSITIVE_INFINITY = 1.0 / 0.0 , the  positive infinity of type double.
				// 	Constructors
			public Double(double  value);	
			//	Constructs a newly allocated Double object that represents the primitive double argument.
			public Double(String  s);
			/*	Constructs a newly allocated Double object that represents the floating- point value of type double represented by the string. The string is converted to a double value as if by the valueOf method. This method throws NumberFormatException,  if the string does not contain a parsable number.  	
			*/	   	
			// 	Methods
			public static long doubleToLongBits(double  value);	
			public double doubleValue();	
			public boolean equals(Object  obj);	
			public float floatValue();	
			public int hashCode();	
			public int intValue();	
			public boolean isInfinite();
			public static boolean isInfinite(double  v);	
			public boolean isNaN();	
			public static boolean isNaN(double  v);	
			public static double longBitsToDouble(long  bits);
			public long longValue();	
			public String toString();	
			public static String toString(double  d);	
			public static Double valueOf(String  s);	
		    }
	The performance of various methods in this class are stated in Table 2.6

Table 2.6

 

Method

Description

doubleToLongBits(double value)

The result is a representation of the floating-point argument according to the IEEE 754 floating-point "double format" bit layout.

Bit 63 represents the sign of the floating-point number. Bits 62-52 represent the exponent. Bits 51-0 represent the significand (sometimes called the mantissa) of the floating-point number.

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

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

If the argument is NaN, the result is 0x7ff8000000000000L.

doubleValue()

The double value represented by this object.

equals(Object obj)


The result is true if and only if the argument is not null and is a Double object that represents a double that has the identical bit pattern to the bit pattern of the double represented by this object.

floatValue()

the double value represented by this object is converted to type float and the result of the conversion is returned.

hashCode()

a hash code value for this object.

intValue()

the double value represented by this object is converted to type 191int and the result of the conversion is returned.

isInfinite()

True if the value represented by this object is positive infinity or negative infinity; false otherwise.

isInfinite(double v)

true if the value of the argument is positive infinity or negative infinity; false otherwise.

isNaN()

true if the value represented by this object is NaN; false otherwise.

isNaN(double v)

true if the value of the argument is NaN; false otherwise.

longBitsToDouble(long bits)

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 0x7f800000 00000000L, the result is positive infinity. If the argument is 0xff80000000000000L, the result is negative infinity. If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffff ffffffffL or in the range 0xfff0000 000000001L through 0xffffffffffffffffL, the result is NaN. All IEEE 754 NaN values are, in effect, lumped together by the Java language into a single value.

longValue()

the double value represented by this object is converted to type long and the result of the conversion is returned.

toString()

The primitive double value represented by this object is converted to a string exactly as if by the method toString of one argumen.

toString(double d)

Creates a string representation of the double argument.

valueOf(String s)

Parses a string into a Double. A newly constructed Double initialized to the value represented by the string argument.

Throws : NumberFormatException, if the string does not contain a parsable number.

Class Float

This class wraps a value of type float in an object. An object of type Float contains a single field whose type is float. In addition, this class provides a number of 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. The structure of this class is as stated below :

	
	public  final  class  java.lang.Float
    					extends  java.lang.Number  
	{
        	// 	Member elements
		public final static float MAX_VALUE;
			//	MAX_VALUE  = 3.40282346638528860e+38, is the largest positive finite value of type 	float.
		public final static float MIN_VALUE;
			//	MIN_VALUE   = 1.40129846432481707e-45, is the smallest positive value of type float. 
		public final static float NaN;
			//	NaN = 0.0f/0.0f , is the Not-a-Number value of type float.
		public final static float NEGATIVE_INFINITY;	
			//	NEGATIVE_INFINITY  = -1.0f/0.0f , is the negative infinity of type float.
		public final static float POSITIVE_INFINITY;	
			//	POSITIVE_INFINITY = 1.0f/0.0f  , is the positive infinity of type float.

			// 	Constructors
		public Float(double  value);
			//	Constructs a newly allocated Float object that represents the argument converted to type float. 	
		public Float(float  value);
			//	Constructs a newly allocated Float object that represents the primitive float argument.
		public Float(String  s);
			/*	Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string. The string is converted to a float value as if by the valueOf method. Throws NumberFormatException, if the string does not contain a parsable number.   
			*/
			// 	Methods
		public double doubleValue();	
		public boolean equals(Object  obj);	
		public static int floatToIntBits(float  value);	
		public float floatValue();	
		public int hashCode();	
		public static float intBitsToFloat(int  bits);	
		public int intValue();	
		public boolean isInfinite();	
		public static boolean isInfinite(float  v);	
		public boolean isNaN();	
		public static boolean isNaN(float  v);
		public long longValue();	
		public String toString();	
		public static String toString(float  f);	
		public static Float valueOf(String  s);
	}
Operations performed by the various methods in trhis class are listed in Table 2.7.

Table 2.7

 

Method

Description

doubleValue()

The float value represented by this object is converted to type double and the result of the conversion is returned.

equals(Object obj)

Returns: true if the objects are the same; false otherwise.

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:

If f1 and f2 both represent Float.NaN,then the equals method returns true, even though Float.NaN==Float.NaN has the value false.

If f1 represents +0.0f while f2 represents -0.0f, or vice versa, the equal test has the value false, even though 0.0f==-0.0f has the value true.

floatToIntBits(float value)

Returns: the bits that represent the floating point number.

The result is a representation of the floating-point argument according to the IEEE 754 floating-point "single precision" bit layout. Bit 31 represents the sign of the floating-point number.

Bits 30-23 represent the exponent. Bits 22-0 represent the significand (sometimes called the mantissa) of the floating-point number.

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

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

If the argument is NaN, the result is 0x7fc00000.

floatValue()

Returns: The float value represented by this object is returned.

hashCode()

Returns: a hash code value for this object.

intBitsToFloat(int bits)

Returns: the single format floating-point value with the same bit pattern.

The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single precision" bit layout. That floating-point value is returned as the result.

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 0x7f8fffff or in the range 0xff800001 through 0xff8fffff, the result is NaN. All IEEE 754 NaN values are, in effect, lumped together by the Java language into a single value194.

intValue()

Returns: The float value represented by this object is converted to type int and the result of the conversion is returned.

isInfinite()

Returns: true if the value value represented by this object is positive infinity or negative infinity; false otherwise.

isInfinite(float v)

Returns: true if the argument is positive infinity or negative infinity; false otherwise.

isNaN()

Returns: true if the value value represented by this object is NaN; false otherwise.

isNaN(float v)

Returns: true if the argument is NaN; false otherwise.

longValue()

Returns: The float value represented by this object is converted to type long and the result of the conversion is returned.

toString()

The primitive float value represented by this object is converted to a String exactly as if by the method toString of one argument

Returns: a String representation of this object.

toString(float f)

Creates a string representation of the float argument.

The values NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY, -0.0, and +0.0 are represented by the strings "NaN", "-Infinity", "Infinity", "-0.0" and "0.0", respectively.

Returns: a string representation of the argument.

valueOf(String s)

Parses a string into a Float.

Returns: a newly constructed Float initialized to the value represented by the String argument.

Throws : NumberFormatException, If the string does not contain a parsable number.

Class Integer

This 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 a number of 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. The body of this class is as stated as below :

	public  final  class  java.lang.Integer
    					extends  java.lang.Number  
	{
		// 	Member elements
	public final static int MAX_VALUE;	
	//	MAX_VALUE = 2147483647, the largest value of type int.
	public final static int MIN_VALUE;	
	//	MIN_VALUE = -2147483648, the smallest value of type int.

	// 	Constructors
	public Integer(int  value);
	//	Constructs a newly allocated Integer object that represents the primitive int argument. 	
	public Integer(String  s);
	/*	Constructs a newly allocated Integer object that represents the value represented by the string The string is converted to an int value as if by the valueOf method.
		Throws : NumberFormatException, if the String does not contain a parsable integer.
	*/

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

	Methods are stated in Table 2.8.

Table 2.8

 

Method

Description

doubleValue()

Returns: The int value represented by this object is converted to type double and the result of the conversion is returned.

equals(Object obj)

The result is true if and only if the argument is not null and is an Integer object that contains the same int value as this object.

floatValue()

Returns: the int value represented by this object is converted to type float and the result of the conversion is returned.


getInteger(String nm)

Determines the integer value of the system property with the specified name. The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty.The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned.

getInteger(String nm, int val)

Determines the integer value of the system property with the specified name. The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned.

getInteger(String nm, Integer val)

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned.

If the property value begins with "0x" or "#", not followed by a minus sign, the rest of it is parsed as a hexadecimal integer exactly as for the method Integer.valueOf with radix 16. If the property value begins with "0" then it is parsed as an octal integer exactly as for the method Integer.valueOf with radix 8. Otherwise the property value is parsed as a decimal integer exactly as for the method Integer.valueOf with radix 10. The second argument is the default value. If there is no property of the specified name, or if the property does not have the correct numeric format, then the second argument is returned.

hashCode()

Returns: a hash code value for this object.

intValue()

Returns: The int value represented by this object is returned.

longValue()

Returns: The int value represented by this object is converted to type long and the result of the conversion is returned.

parseInt(String s)

Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' to indicate a negative value.

Returns: the integer represented by the argument in decimal.

Throws :NumberFormatException, if the string does not contain a parsable integer.

parseInt(String s, int radix)

Parses the string argument as a signed integer in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether Character.digit returns a nonnegative value), except that the first character may be an ASCII minus sign ‘-’ to indicate a negative value. The resulting integer value is returned.198

Returns: the integer represented by the string argument in the specified radix.

Throws : NumberFormatException, if the string does not contain a parsable integer.

toBinaryString(int i)

Creates a string representation of the integer argument as an unsigned integer in base 2. The unsigned integer value is the argument plus 25 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0's.

Returns: the string representation of the unsigned integer value represented by the argument in binary (base 2).

toHexString(int i)

Creates a string representation of the integer argument as an unsigned integer in base 16. The unsigned integer value is the argument plus 25 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0's.

Returns: the string representation of the unsigned integer value represented by the argument in hexadecimal (base 16).

toOctalString(int i)

Creates a string representation of the integer argument as an unsigned integer in base 8. The unsigned integer value is the argument plus 25 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading 0's.

Returns: the string representation of the unsigned integer value represented by the argument in octal (base 8).

toString()

Returns: a string representation of the value of this object in base 10.

toString(int i)

Returns: a string representation of the argument in base 10.

toString(int i, int radix)

Creates a string representation of the first argument in the radix specified by the second argument.

If the radix is smaller than Character.MIN_RADIX or larger than Character. MAX_RADIX, then the radix 10 is used instead. If the first argument is negative, the first element of the result is the ASCII minus characer '-' . If the first argument is not negative, no sign character appears in the result. The following ASCII characters are used as digits: 0123456789abcdefghijklmnopqrstuvwxyz

Returns: a string representation of the argument in the specified radix.

valueOf(String s)

Returns: a newly constructed Integer initialized to the value. represented by the string argument. Throws : NumberFormatException, if the string does not contain a parsable integer.

valueOf(String s, int radix)

Returns: a newly constructed Integer initialized to the value represented by the string argument in the specified radix .198198Throws : NumberFormatException, If the String does not contain a parsable integer.

Class Long

This 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 a number of 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.

	
	public  final  class  java.lang.Long
						extends  java.lang.Number  
	{
			// 	Member elements
		public final static long MAX_VALUE;
		//	MAX_VALUE = 9223372036854775807L , the largest value of type long. 	
		public final static long MIN_VALUE;
		//	MIN_VALUE = -9223372036854775808L , the smallest value of type long. 	

		// 	Constructors
		public Long(long  value);	
		//	Constructs a newly allocated Long object that represents the primitive long argument.
		public Long(String  s);	
		/*	Constructs a newly allocated Long object that represents the value represented by the string. The string is converted to an long value as if by the valueOf method.
			Throws : NumberFormatException, if the String does not contain a parsable long integer.
		*/
		// 	Methods
		public double doubleValue();	
		public boolean equals(Object  obj);	
		public float floatValue();	
		public static Long getLong(String  nm);	
		public static Long getLong(String  nm, long  val);	
		public static Long getLong(String  nm, Long  val);	
		public int hashCode();	
		public int intValue();	
		public long longValue();	
		public static long parseLong(String  s);	
		public static long parseLong(String  s, int  radix);	
		public static String toBinaryString(long  i);
		public static String toHexString(long  i);	
		public static String toOctalString(long  i);	
		public String toString();	
		public static String toString(long  i);
		public static String toString(long  i, int  radix);	
		public static Long valueOf(String  s);	
		public static Long valueOf(String  s, int  radix);	
	}

	Methods are described in Table 2.9.

Table 2.9

 

Method

Description

doubleValue()

Returns:The long value represented by this object is converted to type double and the result of the conversion is returned.

equals(Object obj)

The result is true if and only if the argument is not null and is a Long object that contains the same long value as this object.

Returns : true if the objects are the same; false otherwise.

floatValue()

Returns: The long value represented by this object is converted to type float and the result of the conversion is returned.

getLong(String nm)

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

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as a long value and a Long object representing this value is returned. If there is no property with the specified name, or if the property does not have the correct numeric format, then null is returned.




getLong(String nm, long val)

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

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as a long value and a Long object representing this value is returned.

getLong(String nm, Long val)

Determines the long value of the system property with the specified name. The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as a long value and a Long object representing this value is returned. If the property value begins with "0x" or "#", not followed by a minus sign, the rest of it is parsed as a hexadecimal integer exactly as for the method Long.valueOf with radix 16. If the property value begins with "0" then it is parsed as an octal integer exactly as for the method Long.valueOf with radix 8. Otherwise the property value is parsed as a decimal integer exactly as for the method Long.valueOf with radix 10.

The second argument is the default value. If there is no property of the specified name, or if the property does not have the correct numeric format, then the second argument is returned.

hashCode()

Returns: a hash code value for this object.

intValue()

Returns: the long value represented by this object is converted to type int and the result of the conversion is returned.

longValue()

Returns: the long value represented by this object is returned.

parseLong(String s)

Parses the string argument as a signed decimal long. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' to indicate a negative value.

Returns : the long represented by the argument in decimal.

Throws : NumberFormatException, if the string does not contain a parsable long.

parseLong(String s, int radix)

Parses the string argument as a signed long in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether Character.digit returns a nonnegative value), except that the first character may be an ASCII minus sign ‘-’ to indicate a negative value. The resulting long value is returned.

Returns: the long represented by the string argument in the specified radix. Throws : NumberFormatException, if the string does not contain a parsable integer

toBinaryString(long i)

Creates a string representation of the long argument as an unsigned integer in base 2. The unsigned long value is the argument plus 28 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0's.

Returns: the string representation of the unsigned long value represented by the argument in binary (base 2).

toHexString(long i)

Creates a string representation of the long argument as an unsigned integer in base 16. The unsigned long value is the argument plus216 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0's. Returns: the string representation of the unsigned long value represented by the argument in hexadecimal (base 16).

toOctalString(long i)

Creates a string representation of the long argument as an unsigned integer in base 8.

The unsigned long value is the argument plus 28 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading 0's. Returns: the string representation of the unsigned long value represented by the argument in octal (base 8).

toString()

Returns: a string representation of this object in base 10.

toString(long i)

Returns: a string representation of the argument in base 10.

toString(long i, int radix)

Creates a string representation of the first argument in the radix specified by the second argument.

If the radix is smaller than Character.MIN_RADIX or larger than Character.MAX_RADIX, then the radix 10 is used instead. If the first argument is negative, the first element of the result is the ASCII minus sign '-' . If the first argument is not negative, no sign character appears in the result. The following ASCII characters are used as digits. 0123456789abcdefghijklmnopqrstuvwxyz. Returns: a string representation of the argument in the specified radix.

valueOf(String s)

Returns: a newly constructed Long initialized to the value represented by the string argument. Throws : NumberFormatException, if the String does not contain a parsable

valueOf(String s, int radix)

Returns: a newly constructed Long initialized to the value represented by the string argument in the specified radix. Throws : NumberFormatException, If the String does not contain a parsable long.

Class Math

The class Math contains methods for performing basic numerical operations such as the elementary exponential, logarithm, square root, and trigononetric functions. The structure of this class is stated as below :

	public  final  class  java.lang.Math
    				extends  java.lang.Object
	{
        	// 	Member elements
    	public final static double E;	
		/*	E = 2.7182818284590452354 , the double value that is closer than any other to e, the base of the natural logarithms.
		*/
      	public final static double PI;	
		/*	PI = 3.14159265358979323846 , the double value that is closer than any other to p, the ratio of the circumference of a circle to its diameter.
		*/
      	// 	Methods
    	public static double abs(double  a);	
    	public static float abs(float  a);	
    	public static int abs(int  a);	
    	public static long abs(long  a);	
    	public static double acos(double  a);	
    	public static double asin(double  a);	
    	public static double atan(double  a);	
    	public static double atan2(double  a, double  b);
  	    public static double ceil(double  a);	
   	    public static double cos(double  a);	
    	public static double exp(double  a);	
    	public static double floor(double  a);	
   	    public static double IEEEremainder(double  f1, double  f2);
    	public static double log(double  a);	
    	public static double max(double  a, double  b);	
    	public static float max(float  a, float  b);	
    	public static int max(int  a, int  b);	
    	public static long max(long  a, long  b);	
   	    public static double min(double  a, double  b); 	
    	public static float min(float  a, float  b);	
      	public static int min(int  a, int  b);	
    	public static long min(long  a, long  b);	
    	public static double pow(double  a, double  b);	
    	public static double random();	
   	    public static double rint(double  a);	
   	    public static long round(double  a);	
   	    public static int round(float  a);	
    	public static double sin(double  a);	
   	    public static double sqrt(double  a);	
    	public static double tan(double  a);	
	}
	Methods are described as in Table 2.10.

Table 2.10

 

Method

Description

abs(double a)

Calculates the absolute value of the argument.

Returns: the absolute value of the argument.

abs(float a)

Calculates the absolute value of the argument.

Returns: the absolute value of the argument.

abs(int a)

Calculates the absolute value of the argument. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Note that if the argument is equal to the value of Integer.MIN_VALUE, the most negative representable int value, the result is that same value, which is negative.

Returns: the absolute value of the argument.

abs(long a)

Calculates the absolute value of the argument.If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Note that if the argument is equal to the value of Long.MIN_VALUE, the most negative representable int value, the result is that same value, which is negative.

Returns: the absolute value of the argument.

acos(double a)

Returns: the arc cosine of the argument.

asin(double a)

Returns: the arc sine of the argument.

atan(double a)

Returns: the arc tangent of the argument.

atan2(double a, double b)

Returns: the t component of the polar coordinate the ( p, t ) at corresponds to the cartesian coordinate . (a.b).

ceil(double a)

Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.

cos(double a)

Returns: the cosine of the argument.

exp(double a)

Returns: the value ea, where where e is the base of the natural logarithms.

floor(double a)

Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.

IEEEremainder(double f1, double f2)

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard: the remainder value is mathematically equal to f1/f2 where f2 is the mathematical integer closest to the exact mathematical value of the quotient f1/f2 205205, and if two mathematical integers are equally close to the f1/f2 then f2 is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument.

Returns: the remainder when f1 is divided by f2.

log(double a)

Returns: the value log a, the natural logarithm of a.

max(double a, double b)

Returns: the larger of a and b.

max(float a, float b)

Returns: the larger of a and b

max(int a, int b)

Returns: the larger of a and b.

max(long a, long b)

Returns: the larger of a and b.

min(double a, double b)

Returns: the smaller of a and b

min(float a, float b)

Returns: the smaller of a and b

min(int a, int b)

Returns: the smaller of a and b.

min(long a, long b)

Returns: the smaller of a and b.

pow(double a, double b)

Returns: the value ab.

random()

Returns: a pseudorandom double between 0.0 and 1.0.

rint(double a)

Calculates the closest integer to the argument.

Returns: the closest double value to a that 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.

round(double a)

Calculates the closest long to the argument.

If the argument is negative infinity or any value less than or equal to the value of Long.MIN_VALUE, the result is equal to the value of Long.MIN_VALUE. If the argument is positive infinity or any value greater than or equal to the value of Long.MAX_VALUE, the result is equal to the value of Long.MAX_VALUE..

Returns: the value of the argument rounded to the nearest long value.

round(float a)

Calculates the closest int to the argument.

If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE. If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.

Returns: the value of the argument rounded to the nearest int value.

sin(double a)

Returns: the sine of the argument

sqrt(double a)

Returns: the value of square root of a. If the argument is NaN or less than zero, the result is NaN.

tan(double a)

Returns: the tangent of the argument.

Class Number

The abstract class Number is the superclass of classes Float. Double, Integer, and Long. Subclasses of Number must provide methods to convert the represented numeric value to int, long, float, and double.

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

Table 2.11

Method

Description

doubleValue()

Returns: The numeric value represented by this object is returned after conversion to type double.

floatValue()

Returns: The numeric value represented by this object is returned after conversion to type float.

intValue()

Returns: The numeric value represented by this object is returned after conversion to type int.

longValue()

Returns : The numeric value represented by this object is returned after conversion to type long.

Class Object

Class Object is the root of the class hierarchy. Every class has Object as a superclass. parent. All objects, including arrays, implement the methods of this class.

		public  class  java.lang.Object
		{
				// 	Constructors
			public Object();	
			//	Allocates a new instance of class Object.
			// 	Methods
			protected Object clone();	
			public boolean equals(Object  obj);	
			protected void finalize();
			public final Class getClass();	
			public int hashCode();	
			public final void notify();	
			public final void notifyAll();	
			public String toString();	
			public final void wait();	
			public final void wait(long  timeout);	
			public final void wait(long  timeout, int  nanos);
		}
	Methods are described in Table 2.12.

Table 2.12

 

Method

Description

clone()

The clone method of class Object creates a new object of the same class as this object. It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No constructor is called. The clone method of class Object will only clone an object whose class indicates that it is willing for its instances to be cloned. A class indicates that its instances can be cloned by declaring that it implements the Cloneable Interface.

Throws : OutOfMemoryError , if there is not enough memory. Also throws CloneNotSupportedException, when the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

equals(Object obj)

Indicates whether some other object is "equal to" this one. The equals method implements an equivalence relation :

It is reflexive: for any reference value x, x.equals(x) should return true.

It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.

It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true then x.equals(z) should return true.

It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false.

For any reference value x, x.equals(null) should return false. For any reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).

finalize()

The finalize method is 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 in order to dispose of system resources or to perform other cleanup. Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored. The finalize method in Object does nothing

getClass()

Determines the run-time class of an object. Returns: the object of type Class that represents the run-time class of the object .

hashCode()

Calculates a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.Hashtable.The general contract of hashCode is :

Whenever invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer. This integer need not remain consistent from one execution of an application to another execution of the same application. 208

If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must prtoduce the same integer result.

notify()

Wakes up a single thread that is waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

By executing a synchronized instance method of that object.

By executing the body of a synchronized statement that synchronizes on the object.

For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can only an object's monitor.

Throws : IllegalMonitorStateException, If the current thread is not the owner of this object's monitor

notifyAll()

Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.This method should only be called by a thread that is the owner of this object's monitor.

Throws IllegalMonitorStateException, If the current thread is not the owner of this object's monitor.

toString()

Creates 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. 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.

wait()

Waits to be notified by another thread of a change in this object.

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notufyAll method. 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 thred can become the owner of a monitor.

Throws : IllegalMonitorStateException, if the current thread is not the owner of the object's monitor. Also Throws : InterruptedException, if another thread has interrupted this thread.

wait(long timeout)

Waits to be notified by another thread of a change in this object.

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 :

Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.

The timeout period, specified by the timeout argument is milliseconds, has elapsed.

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.

wait(long timeout, int nanos)

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 notif ication before giving up.

Class Process

The execution methods returns an instance of a subclass of Process that can be used to control the process and obtain information about it.

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

        	// 	Methods
    	public abstract void destroy();	 
    	public abstract int exitValue();	 
    	public abstract InputStream getErrorStream();	 
    	public abstract InputStream getInputStream();	 
    	public abstract OutputStream getOutputStream();	 
    	public abstract int waitFor();	 
	}
	Methods are as shown in Table 2.13. 

Table 2.13  

 

Method

Description

destroy()

Kills the subprocess.

exitValue()

Returns: the exit value of the subprocess. Throws : IllegalThreadStateException, if the subprocess has not yet terminated.

getErrorStream()

Gets the error stream of the subprocess.

Returns: the input stream connected to the error stream of the subprocess. This stream is usually unbuffered.

getInputStream()

Gets the input stream of the subprocess.

Returns: the input stream connected to the normal output of the subprocess. This stream is usually buffered.

getOutputStream()

Gets the output stream of the subprocess.

Returns: the output stream connected to the normal input of the subprocess. This stream is usually buffered.

waitFor()

Waits for the subprocess to complete. This method returns immediately if the subprocess has already terminated.

Returns: the exit value of the process.

Throws : InterruptedException., if the waitFor was interrupted.

Class Runtime

Every Java application has a single instance of class Runtime which 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.

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

Table 2.14  

Method

Description

exec(String command)

Executes the string command in a separate process.The command argument is parsed into tokens and then executed as a command in a separate process. This method has exactly the same effect as exec(command, null).

Returns: a Process object for managing the subprocess. Throws : SecurityException, if the current thread cannot create a subprocess.

exec(String command, String envp[])

Executes the 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; it then performs the call exec(cmdarray, envp).

Returns: a Process object for managing the subprocess. Throws : SecurityException, if the current thread cannot create a subprocess.



exec(String cmdarray[])

Executes the string command in a separate process with the specified environment.. The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null).

Returns: a Process object for managing the subprocess. Throws : SecurityException, if the current thread cannot create a subprocess.

exec(String cmdarray[], String envp[])

Executes the string command in a separate process with the specified arguments and the specified environment. If there is a security manager, its checkExec method is called with the first component of the array cmdarray as its argument. This may result in asecurity exeception. Given an array of strings cmdarray, representing the tokens of a command line, and an array of strings envp, representing an "environment" that defines system properties, this method creates a new process in which to execute the specified command. Returns: a Process object for managing the subprocess. Throws : SecurityException, if the current thread cannot create a subprocess

exit(int status)

Terminates the currently running Java Virtual Machine. This method never returns normally. If there is a security manager, its checkExit methodis called with the status as its argument. This may rseult in a security exception. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination

Throws : SecurityException, if the current thread cannot exit with the specified status.

freeMemory()

Determines the amount of free memory in the system. The value returned by this method is always less than the value returned by the total-Memory method. Calling the gc method may result in increasing the value returned by freeMemory. Returns: an approximation to the total amount of memory currently available for future allocated objects, measured in bytes, is returned.

gc()

Calling this method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made its best effort to recycle all unused objects. The name gc stands for "garbage collector." The Java Virtual Machine performs this recycling process automatically as needed even if the gc method is not invoked explicitly.

getLocalizedInputStream (InputStream in)

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 charascter set to Unicode. If the argument is already a localized stream, it may be returned as the result.

Returns: a localized input stream.

getLocalizedOutputStream (OutputStream out)

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 character set 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.

Returns: a localized output stream.

getRuntime()

Returns: the Runtime object associated with the current Java application.

load(String filename)

Loads the given filename as a dynamic library. The filename argument must be a complete path name. If there is a security manager, its checkLink method is called with tyhe filename as its argument. This may result in a security exception.

Throws : UnsatisfiedLinkError, if the file does not exist.

Throws : SecurityException, if the current thread cannot load the specified dynamic library.

loadLibrary(String libname)

Loads the dynamic library with the specified library name. The mapping from a library name to a specific filename is done is a system-specific manner. First, if there is a security manager, its checkLink method is called with the filename as its argument. this may result in security exception. If this method is called more than once with the same library name, the second and subsequent calls are ignored.

Throws : UnsatisfiedLinkError, if the library does not exist Throws : SecurityException, if the current thread cannot load the specified dynamic library.

runFinalization()

Calling this method suggests that the Java Virtual Machine expend effort toward running the finalize methods of objects that have been foun to be discarded but whose finalized methods have not yet been run. when control returns from the method call, the Java Virtual Machine has made a best effort to complete all outstanding finalizations. The Java Virtual Machine performs the finalization process automatically as needed if the runFinalization method is not invoked explicitly.

totalMemory()

Determines the total amount of memory in the Java Virtual Machine.

Returns: the total amount of memory currently available for allocating objects, measured in bytes.

traceInstructions(boolean on)

If the boolean argument is true, this method asks the Java Virtual Machine to print out a detailed trace of each instruction in the Java Virtual Machine as it is executed. The virtual machine may ignore this request if it does not support this feature. The destination of the trace output is system-dependent. If the boolean argument is false, this method causes the Java Virtual Machine to stop performing a detailed instruction trace it is performing.




traceMethodCalls(boolean on)

If the boolean argument is true, this method asks the Java Virtual Machine to print out a detailed trace of each method in the Java Virtual Machine as it is called. The virtual machine may ignore this request if it does not support this feature. The destination of the trace output is system-dependent. If the boolean argument is false, this method causes the Java Virtual Machine to stop performing a detailed method trace it is performing.

Class SecurityManager

The security manager is an abstract 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 the operation is being performed by a class created via a class loader rather than installed locally. Classes loaded via a class loader (especially if they have been downloaded over a network) may be less trustworthy than classes from files installed locally. The application has the option of allowing or disallowing the operation

The SecurityManager class contains a large number of methods whose names 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 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 :

	public abstract  class  java.lang.SecurityManager
    					extends  java.lang.Object   
	{
        	// 	Member elements
    	protected boolean inCheck; 
		//	This field is true if there is a security check in progress; false otherwise.

        	// 	Constructors
    	protected SecurityManager();
		/*	Constructs a new SecurityManager. An application is not allowed to create a new security manager if there is already a current security manager.Throws :  SecurityException, if a security manager already exists.  	 
		*/
        	// 	Methods
    	public void  checkAccept(String  host, int  port);	 
    	public void checkAccess(Thread  g);	 
    	public void checkAccess(ThreadGroup  g);	 
    	public void checkConnect(String  host, int  port);	 
    	public void checkConnect(String  host, int  port, Object  context);
    	public void checkCreateClassLoader();	 
    	public void checkDelete(String  file);	 
    	public void checkExec(String  cmd);	 
    	public void checkExit(int  status);	 
    	public void checkLink(String  lib);	 
    	public void checkListen(int  port);	 
    	public void checkPackageAccess(String  pkg);	 
    	public void checkPackageDefinition(String  pkg);	 
    	public void checkPropertiesAccess();	 
    	public void checkPropertyAccess(String  key); 
    	public void checkRead(FileDescriptor  fd);	 
    	public void checkRead(String  file);	 
    	public void checkRead(String  file, Object  context);	 
    	public void checkSetFactory();	 
    	public boolean checkTopLevelWindow(Object  window);	 
    	public void checkWrite(FileDescriptor  fd);	 
    	public void checkWrite(String  file);	 
    	protected int classDepth(String  name); 
    	protected int classLoaderDepth(); 
    	protected ClassLoader currentClassLoader();	 
    	protected Class[] getClassContext();	 
    	public boolean getInCheck();	 
    	public Object getSecurityContext();	 
    	protected boolean inClass(String  name);	 
    	protected boolean inClassLoader();	 
	}
Operation performed by the various methods are described in Table 2.15.

Table 2.15

 

Method

Description

checkAccept(String host, int port)

This method should throw a SecurityException if the calling thread is not permitted to accepting 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. The checkAccept method for class SecurityManager always throws a SecurityException.

checkAccess(Thread g)

This method should throw 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. The checkAccess method for class SecurityManager always throws a SecurityException.

checkAccess(ThreadGroup g)

This method should throw 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. The checkAccess method for class SecurityManager always throws a SecurityException.

checkConnect(String host, int port)

This method should throw 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 of -1 indicates that the calling method is attempting to determine the IP address of the specified host name. The checkConnect method for class SecurityManager always throws a SecurityException.

checkConnect(String host, int port, Object context)

This method should throw 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 of -1 indicates that the calling method is attempting to determine the IP address of the specified host name. The checkConnect method for class SecurityManager always throws a SecurityException.

checkCreateClassLoader()

This method should throw a SecurityException if the calling thread is not allowed to create a new class loader216.The checkCreateClassLoader method for class SecurityManager always throws a SecurityException.

checkDelete(String file)

This method should throw a SecurityException if the calling thrad is not allowed to delete the specified file.This method is invoked for the current security manager by the delete method of class File. The checkDelete method for class SecurityManager always throws a Security Exception.

checkExec(String cmd)

This method should throw a SecurityException if the calling thread is not allowed to create a subprocss. This method is invoked for the current security manager by the exec methods of class Runtime. The checkExec method for class SecurityManager always throws a SecurityException.

checkExit(int status)

This method should throw a SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified access code. This method is invoked for the current security manager by the exit method of class Runtime. A status of 0 indicates success; other values indicate various errors. The checkExit method for class SecurityManager always throws a SecurityException.

checkLink(String lib)

This method should throw 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 file name. This method is invoked for the current security manager by methodd load, and loadLibrary of class Runtime. The checkLink method for class SecurityManager always throws a SecurityException.

checkListen(int port)

This method should throw a SecurityException if the calling thread is not allowed to wait for a connection request on the specified local port number. The checkListen method for class SecurityManager always throws a SecurityException.

checkPackageAccess(String pkg)

This method should throw a SecurityException if the calling thread is allowed to access the package specified by the argument.This method is used by the loadClass method of class loaders. The checkPackageAccess method for class SecurityManager always throws a SecurityException.

checkPackageDefinition(String pkg)

This method should throw a SecurityException if the calling thread is not allowed to define classes in the package specified by the argument. This method is used by the loadClass method of some class loaders. The checkPackageDefinition method for class SecurityManager always throws a SecurityException.

checkPropertiesAccess()

This method should throw a SecurityException if the calling thread is not allowed to access or modify the system properties. This method is used by the getProperties and setProperties methods of class System. The checkPropertiesAccess method for class SecurityManager always throws a SecurityException.

checkPropertyAccess(String key)

This method should throw 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. The checkPropertiesAccess method for class SecurityManager always throws a SecurityException.

checkRead(FileDescriptor fd)

This method should throw a SecurityException if the calling thread is not allowed to read from the specified file descriptor. The checkRead method for class SecurityManager always throws a SecurityException.

checkRead(String file)

This method should throw a SecurityException if the calling thread is not allowed to read the file specified by the string argument. The checkRead method for class SecurityManager always throws a SecurityException.

checkRead(String file, Object context)

This method should throw 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. The checkRead method for class SecurityManager always throws a SecurityException.

checkSetFactory()

This method should throw a SecurityException if the calling thread is not allowed to set the socket factor used by ServerSocket or Socket, or the stream handler factory used by URL. The checkSetFactory method for class SecurityManager always throws a SecurityException.

checkTopLevelWindow(Object window)

This method should return 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. The checkSetFactory method for class SecurityManager always return false.

Returns : true if the caller is trusted to put up top-level windows; false otherwise.

checkWrite(FileDescriptor fd)

This method should throw a SecurityException if the calling thread is not allowed to write to the specified file descriptor218.

The checkWrite method for class SecurityManager always throws a SecurityException.

Throws : SecurityException, if the caller does not have permission to access the specified file descriptor.

checkWrite(String file)

This method should throw a SecurityException if the calling thread is not allowed to write to the file specified by the string argument. The checkWrite method for class SecurityManager always throws a SecurityException.,

Throws : SecurityException, if the caller does not have permission to access the specified file.

classDepth(String name)

Determines the stack depth of a given class.

Returns : The depth on the stack frame of the first occurrence of a method from a class with the specified name; -1 if such a frame cannot be found.

classLoaderDepth()

Determines the stack stack of the most recently executing method from a class defined using a class loader.

Returns : the depth on the stack frame of the most recent occurrence of a method from a class defined using a class loader; returns -1 if there is no occurrence of a method from a class defined using a class loader

currentClassLoader()

Determines the most recent class loader executing on the stack.

Returns : The class loader of the most recent occurrence on the stack of a method from a class defined using a class loader; returns null if there is no occurrence on the stack of a method from a class defined using a class loader.

getClassContext()

Calculates the current execution stack, which is returned as an array of classes. The length of the array is the number of methods on the execution stack. The element at index 0 is the class of the currently executing method. The element at index 1 is the class of that method's caller. And so forth. Returns : the execution stack.

getInCheck()

Returns : the value of the inCheck field. This field should contain true if a security check is in progress; false otherwise.

getSecurityContext()

Creates an object when encapsulates the current execution environment. The result of this method is used by the three-argument checkConnect method and by the two-argument checkRead method. These methods are needed because a trusted method may be called upon to read a file or open a socket on behalf of another method. The trusted method needs to determine if the other (possibly untrusted) method would be allowed to perform the operation.on its own..

Returns : an implementation-dependent object which encapsulates sufficient information about the current execution environment to perform some security checks later.

inClass(String name)

Returns : true if a method from a class with the specified name is on the execution stack; false otherwise.

inClassLoader()

Returns : true if a method from a class defined using a class loader is on the execution stack.

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.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. Following is the structure of this class :

	public  final  class  java.lang.String
    					extends  java.lang.Object   
	{
        // 	Constructors
		public String();	
		//	Allocates a new String containing no characters. 
		public String(byte  ascii[], int  hibyte);	
		/*	Allocates a new String containg characters constructed from an array of 8- bit integer values. Each character c in the resultoing string is constructed from the corresponding component b in the byte array such that :
					c == (char)(((hibyte & 0xff) << 8 | (b & 0xff))
			Parameters : 
				ascii - the bytes to be converted to characters  
				hibyte - the top 8 bits of each 16-bit Unicode character
		*/
		public String(byte  ascii[], int  hibyte, int  offset, int  count);
		/*	Allocates a new String constructed from a subarray of an array of 8-bit integer values. The offset argument is the index of the first byte of the subarray, and the count argument specifies the length of the subarray. Each byte in the subarray is converted to a char as specified in the method above.                                                              Throws :  StringIndexOutOfBoundsException,  if the offset or count argument is invalid.			
		*/
		public String(char  value[]);	
		/*	Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. 
		*/
		public String(char  value[], int  offset, int  count);	 
		/*	Allocates a new String that contains characters from a subarray of the character array argument. The offset argument is the index of the first character of the subarray and the count argument specifies the length of the subarray.                    			Throws StringIndexOutOfBoundsException if the offset and count arguments index characters outside the bounds of the value array.
		*/
		public String(String  value);
		//	Allocates a new string that contains the same sequence of characters as the string 	argument. 	 
		public String(StringBuffer  buffer);	 
		//	Allocates a new string that contains the sequence of characters currently contained in the string buffer argument.

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

Table 2.16

 

Method

Description

charAt(int index)

Returns : The character at the specified index of this string. The first character is at index 0.

Throws : StringIndexOutOfBoundsException, if the index is out of range.

compareTo(String anotherString)

Compares two strings lexicographically.

Returns : The value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this string is lexicographically greater than the string argument.

concat(String str)

Concatenates the string argument to the end of this string. If the length of the argument string is zero, then this object is returned.

Returns : A string that represents the concatenation of this object's characters followed by the string argument's characters.

copyValueOf(char data[])

Returns: a String that contains the characters of the character array.

copyValueOf(char data[], int offset, int count)

Returns : a String that contains the characters of the specified subarray of the character array.

endsWith(String suffix)

Returns : true, if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise.

equals(Object anObject)

The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.


Returns : true, if the String's are equal; false otherwise.

equalsIgnoreCase(String anotherString)

The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object, where case is ignored. Two characters are considered the same, ignoring case, if at least one of the following is true :

The two characters are the same (as compared by the == operator).

Applying the method Character.toUppercase to each character produces the same result.

Applying the method Character.toLowercase to each character produces the same result.

Two sequence of characters are the same, ignoring case, if the sequences have the same length and corresponding characters are the same, ignoring case.

Returns : true, if the String's are equal, ignoring case; false otherwise.

getBytes(int srcBegin, int srcEnd, byte dst[],

int dstBegin)

Copies characters from this string into the destination byte array. Each byte receives the 8 low-order bits of the corresponding character. 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, converted to bytes, are copied into the subarray of dst starting at index dstBegin and ending at index:

dstbegin+(srcEnd-srcBegin)-1

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

Copies characters from this string into the destination character array. The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1 (thus 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 : 223

dstbegin+(srcEnd-srcBegin)-1

hashCode()

Returns : a hash code value for this object.

indexOf(int ch)

Returns : the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

indexOf(int ch, int fromIndex)

Returns : the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur.

indexOf(String str)

Returns : if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.

indexOf(String str, int fromIndex)

Returns : if the string argument occurs as a substring within this object at a starting index no smaller than fromIndex then the index of the first character of the first such substring is returned. If it does not occur as a substring starting at fromIndex or beyond, -1 is returned.


intern()

Creates a canonical representation for the string object. If s and t are strings such that s.equals(t), it is guaranteed that

s.intern() == t.intern().

Returns : a string that has the same contents as this string, but is guaranteed to be from a pool of unique strings.

lastIndexOf(int ch)

Returns : the index of the last occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.

lastIndexOf(int ch, int fromIndex)

Returns : the index of the last occurrence of the character in the character sequence represented by this object that is less than or equal to from-Index, or -1 if the character does not occur before that point.

lastIndexOf(String str)

Returns : if the string argument occurs as a substring within this object, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.

lastIndexOf(String str, int fromIndex)

Returns : if the string argument occurs as a substring within this object at a starting index no greater than fromIndex then the index of the first character of the lastsuch substring is returned. If it does not occur as a substring starting at fromIndex or earlier, -1 is returned.

length()

Returns : the length of the sequence of characters represented by this object is returned.

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

Determines if two string regions are equal. If toffset or ooffset is negative, or if toffset+length is greater than the length of this string, or if ooffset+length is greater than the length of the string argument, then this method returns false.

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

Determines if two string regions are equal. If toffset or ooffset is negative, or if toffset+length is greater than the length of this string, or if ooffset+length is greater than the length of the string argument, then this method returns false224.

replace(char oldChar, char newChar)

Returns a new string resulting from replacing all occurrences of oldChar in this nstring with newChar. If the character oldChar does not occur in the character sequence represented by this object, then this string is returned.

startsWith(String prefix)

Returns : true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.

startsWith(String prefix, int toffset)

Returns : true if the character sequence represented by the argument is a prefix of the substring of this object starting at index toffset; false otherwise.

substring(int beginIndex)

Creates a new string that is a substring of this string. The substring begins at the specified index and extends to the end of this string.

Returns : The specified substring.

Throws : StringIndexOutOfBoundsException, if the beginIndex is out of range.

substring(int beginIndex, int endIndex)

Creates a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1.

Throws : StringIndexOutOfBoundsException, If the beginIndex or the endIndex is out of range.

toCharArray()

Returns : a newly allocated character array whose length is the length of this string and whose contents is initialized to contain the character sequence represented by this string.

toLowerCase()


Converts a string to lowercase. If no character in this string has a different lowercase version, then this string is returned. Otherwise, a new string is allocated, whose length is identical to this string, and such that each character which has a difference lowercase version is mapped to this lower case equivalent.

Returns : the string, converted to lowercase.

toString()

This object (which is already a string!) is itself returned.

toUpperCase()

Converts a string to uppercase. If no character in this string has a different uppercase version, then this string is returned. Otherwise, a new string is allocated, whose length is identical to this string, and such that each character which has a difference uppercase version is mapped to this uppercase equivalent.

Returns : the string, converted to uppercase.

trim()

Removes white space from both ends of a string. All characters that have codes less than or equal to '\u0020' (the space character) are considered to be white space.

Returns : this string, with whitespace removed from the front and end.

valueOf(boolean b)

Creates the string representation of the boolean argument.

Returns : if the argument is true, a string equal to "true" is returned; otherwise, a string equal to "false" is returned.

valueOf(char c)

Creates the string representation of the char argument.

Returns : a newly allocated string of length one containing as its single characer the argument c.

valueOf(char data[])

Creates the string representation of the char array argument. Returns : a newly allocated string representing the same sequence of characters contained in the character array argument.

valueOf(char data[], int offset, int count)

Creates the string representation of a specific subarray of the char array argument. The offset argument is the index of the first character of the subarray. The count argument specifies the length of the subarray.

Returns : a newly allocated string representing the sequence of characters contained in the subarray of the character array argument.

valueOf(double d)

Creates the string representation of the double argument.

The representation is exactly the one returned by the Double-.toString method of one argument.

Returns : a newly allocated string containing a string representation of the double argument.


valueOf(float f)

Creates the string representation of the float argument. The representation is exactly the one returned by the Float.toString method of one argument.

Returns : a newly allocated string containing a string representation of the float argument.

valueOf(int i)

Creates the string representation of the int argument.

The representation is exactly the one returned by the Integer.toString method of one argument. Returns: a newly allocated string containing a string representation of the int argument.

valueOf(long l)

Creates the string representation of a the long argument. The representation is exactly the one returned by the Long.toString method of one argument.

Returns : a newly allocated string containing a string representation of the long argument.

valueOf(Object obj)

Creates the string representation of the Object argument. Returns : if the argument is null, then a string equal to "null"; otherwise the value of obj.toString() is returned.

Class StringBuffer

A string buffer implements a mutable sequence of characters. 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. String buffers are used by the compiler to implement the binary string concatentation operator +.

For example the code x = "a" + 4 + "c" is compiled to the equivalent of :

x=newStringBuffer().append("a").append(4).append("c").toString()

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" while z.insert(4, "le") would alter the string buffer to contain "starlet".

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.

	The structure of this class is shown as below :
		public  class  java.lang.StringBuffer
						extends  java.lang.Object   
		{
				// Constructors
			public StringBuffer();
			//	Constructs a string buffer with no characters in it, and an initial capacity of  16 characters. 	 
			public StringBuffer(int  length); 
			/*	Constructs a string buffer with no characters in it, and an initial capacity specified by the length argument.
				Throws :  NegativeArraySizeException, if the length argument is less than zero.
			*/
			public StringBuffer(String  str);
			/*	Constructs a string buffer so that it represents the same sequence of characters as the string argument. The initial capacity of the string buffer is 16 plus the length of the string argument.
			*/ 	 
				// 	Methods
			public StringBuffer append(boolean  b);	 
			public StringBuffer append(char  c);	 
			public StringBuffer append(char  str[]);	 
			public StringBuffer  append(char  str[], int  offset, int  len);
			public StringBuffer append(double  d);	 
			public StringBuffer append(float  f); 
			public StringBuffer append(int  i);	 
			public StringBuffer append(long  l);	 
			public StringBuffer append(Object  obj);	 
			public StringBuffer append(String  str);	 
			public int capacity();	 
			public char charAt(int  index);	 
			public void ensureCapacity(int  minimumCapacity); 
			public void getChars(int  srcBegin, int  srcEnd,	char  dst[], int dstBegin);
			public StringBuffer insert(int  offset, boolean  b);	 
			public StringBuffer insert(int  offset, char  c); 
			public StringBuffer insert(int  offset, char  str[]);	 
			public StringBuffer insert(int  offset, double  d); 
			public StringBuffer insert(int  offset, float  f);	 
			public StringBuffer insert(int  offset, int  i);	 
			public StringBuffer insert(int  offset, long  l);	 
			public StringBuffer insert(int  offset, Object  obj);	 
			public StringBuffer insert(int  offset, String  str);	 
			public int length();	 
			public StringBuffer length(); 
			public void setCharAt(int  index, char  ch);	 
			public void setLength(int  newLength); 
			public String toString();	 
		}

	Methods are described in Table 2.17.

Table 2.17

 

Method

Description

append(boolean b)

Appends the string representation of the boolean argument to the string buffer. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this string buffer.

Returns : this string buffer.

append(char c)

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

Argument is appended to the contents of this string buffer. The length of this string buffer increases by one.

Returns: this string buffer

append(char str[])

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

The characters of the array argument are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the length of the argument.

Returns: this string buffer.

append(char str[], int offset, int len)

Appends the string representation of a subarray of the char array argument to this string buffer. Characters of the character array str, starting at index offset, are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the value of len.

Returns : this string buffer.

append(double d)

Appends the string representation of the double argument to this string buffer. The argument is converted to a string as if by the method String.valueOf , and the characters of that string are then appended to this string buffer.228

Returns: this string buffer.

append(float f)

Appends the string representation of the float argument to this string buffer. The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to the string buffer. Returns :this string buffer.

append(int i)

Appends the string representation of the int argument to this string buffer. The argument is converted to a string as if by the method String.valueOf , and the characters of that string are then appended to the string buffer. Returns :this string buffer.

append(long l)

Appends the string representation of the long argument to this string buffer. The argument is converted to a string as if by the method String.valueOf , and the characters of that string are then appended to the string buffer.

Returns :this string buffer.

append(Object obj)

Appends the string representation of the Object argument to this string buffer. The argument is converted to a string as if by the method String.valueOf , and the characters of that string are then appended to the string buffer.

Returns : this string buffer.

append(String str)

Appends the string to this string buffer. The characters of the String argument are appended, in order, to the contents of this string buffer, increasing the length of this string buffer by the length of the argument.

capacity()

Returns : the current capacity of this string buffer.

charAt(int index)

Determines the character at a specific index in this string buffer. The first character of a string buffer is at index 0, the next at index 1, and so on, for array indexing. The index argument must be greater than or equal to 0, and less than the length of this string buffer.

Returns: the character at the specified index of this string buffer.

Throws:StringIndexOutOfBoundsException, if the index is invalid.

ensureCapacity(int minimumCapacity)

If the current capacity of this string buffer is less than the argument, then a new internal buffer is allocated with greater capacity. The new capacity is the larger of:

the minimumCapacity argument

twice the old capacity, plus 2

If the minimumCapacity argument is nonpositive, this method takes no action and simply returns.

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

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.

Throws:StringIndexOutOfBoundsException, if there is an invalid index into the buffer.



insert(int offset, boolean b)

Inserts the string representation of the boolean 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 appended to the 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.

Throws:StringIndexOutOfBoundsException, if the offset in invalid.

insert(int offset, char c)

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 offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset is invalid.

insert(int offset, char str[])

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.

Throws:StringIndexOutOfBoundsException, if the offset is invalid.

insert(int offset, double d)

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.

Returns: this string buffer.

Throws : StringIndexOutOfBoundsException, if the offset in invalid.

insert(int offset, float f)

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.

Returns: :this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset is invalid.

insert(int offset, int i)

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 indserted 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.230

Returns : this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset in invalid.

insert(int offset, long l)

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 indicated offset. The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffrer.

Returns : this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset is invalid

insert(int offset, Object obj)

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.

Returns : this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset is invalid.

insert(int offset, String str)

Inserts the string into this string buffer. The characters of the String argument are inserted, in order, into this string buffer at the indicated offset. The length of the of this string buffer is increased by the length of the argument. The offset argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.

Returns: this string buffer.

Throws:StringIndexOutOfBoundsException, if the offset is out of range.

length()

Returns : the number of characters in this string buffer.

reverses()

The character sequence contained in this string buffer is replaced by the reverse of the sequence.

Returns : this string buffer.

setCharAt(int index, char ch)

The character at the specified index of this string buffer is set to ch. The offset argument must be greater than or equal to 0, and less than the length of this string buffer.

Throws:StringIndexOutOfBoundsException, if the index is invalid.

setLength(int newLength)

If the newLength argument is less than the current length of the string buffer, the string buffer is turncated to contain exactly the number of characters given by the newLength argument. If the newLength argument is greater than or equal to the current length, sufficient null characters ('\u0000') are appended to the string buffer so that length becomes the newLength argument. The newLength argument must be greater than or equal to zero.

Throws:StringIndexOutOfBoundsException, if the newLength argument is invalid.

toString()

A new String object is allocated and initialized to contain the character sequence currently represented by this string buffer. This String is then returned. Subsequent changes to the string buffer do not affect the contents of the String.

Class System

The System class contains a number of useful member elements, 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.

	public  final  class  java.lang.System
						extends  java.lang.Object   
	{
			// 	Member elements
		public static PrintStream err;	
		/*	The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user. By convention, this output stream is used to display error messages or other information that should come to the immediate attention of a user even if the principal output stream, the value of the variable out, has been redirected to a file or other destination that is typically not continuously monitored. 
		*/
		public static InputStream in;	 
		/*	The "standard" input stream. This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user.
		*/
		public static PrintStream out;	
		/*	The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user. For simple standalone Java applications, a typical way to write a line of output data is System.out.println(data); See the println methods in class PrintStream. 
		*/
			// 	Methods
		public static void arraycopy(Object  src, int  src_position,Object  dst, int  dst_position, int  length);
		public static long currentTimeMillis();	 
		public static void exit(int  status);	 
		public static void gc();	 
		public static Properties getProperties();	 
		public static String getProperty(String  key);	 
		public static String getProperty(String  key, String  def);	 
		public static SecurityManager getSecurityManager(); 
		public static void load(String  filename);	 
		public static void loadLibrary(String  libname);	 
		public static void runFinalization();	 
		public static void setProperties(Properties  props); 
		public static void setSecurityManager(SecurityManager  s);	 
	}
	Methods are described as in Table 2.18.

Table 2.18

 

Method

Description

arraycopy(Object src, int srcOffset, Object dst, int dstOffset, int length)

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 argument array. If any of the following is true, an ArrayStoreException is thrown and the destination is not modified:

  • The src argument refers to an object that is not an array.

  • The dst argument refers to an object that is not an array.

  • The src argument and dst argument refer to arrays whose component types are different primitive types.

  • The src argument refers to an array with a primitive component type and the dst argument refers to an array with a reference component type.

  • The src argument refers to an array with a reference component type and the dst argument refers to an array with a primitive component type.The srcOffset argument is negative.

  • The dstOffset argument is negative.

  • The length argument is negative.

  • srcOffset+length is greater than src.length, the length of the source array.

  • dstOffset+length is greater than dst.length, the length of the destination array.

    Throws : ArrayIndexOutOfBoundsException, if copy would cause access of data outside array bounds; ArrayStoreException, if an element in the src array could could not be stored into the dest array due to a type mismatch

  • currentTimeMillis()

    Gets the current time.

    Returns : the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

    exit(int status)

    Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination. This method calls the exit method in class Runtime. This method never returns normally.

    Throws : SecurityException, if the current thread cannot exit with the specified status.

    gc()

    This method call the gc method in class Runtime.Calling this method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all unused objects.

    getProperties()

    Determines the current system properties. 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 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 version number
    java.vendor Java-vendor-specific string
    java.vendor.url Java vendor URL
    java.home Java installation directory
    java.class.version Java class format version number
    java.class.path Java classpath
    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 account name
    user.home User home directory
    user.dir User's current working directory

    Throws : SecurityException, if the current thread cannot access the system properties.

    getProperty(String key)

    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 system exception. 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 234getProperties method.

    Returns : the string value of the system property, or null if there is no property with that key.

    Throws : SecurityException, if the current thread cannot access the system properties or the specified property.

    getProperty(String key, String def)

    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.

    Returns : the string value of the system property, or the default value if there is no property with that key.

    Throws : SecurityException, if the current thread cannot access the system properties or the specified property.


    getSecurityManager()

    Returns : if a security manager has already been established for the current application, then that security manager is returned; Otherwise, null is returned.

    load(String filename)

    Loads the given filename as a dynamic library. The filename argument must be a complete path name. This method calls the load method in class Runtime.

    Throws : UnsatisfiedLinkError, if the file does not exist;

    Throws : SecurityException, if the current thread cannot load the specified dynamic library.

    loadLibrary(String libname)

    Loads the system library specified by the libname argument. The manner in which a library name is mapped to the actual system library is system dependent.

    Throws : UnsatisfiedLinkError, if the library does not exist;

    Throws : SecurityException, if the current thread cannot load the specified dynamic library.

    runFinalization()

    This method calls the runFinalization method in class Runtime. Calling this method suggests that the Java Virtual Machine expend effort toward running the finalize methods of objects that have been found to be discarded but whose finalize methods have not yet been run. When control returns from the method call, the Java Virtual Machine has made a best effort to complete all outstanding finalizations.

    setProperties(Properties props)

    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 method. If the argument is null, then the current set of system properties is forgotten.

    Throws : SecurityException, if the current thread cannot set the system properties.

    setSecurityManager(SecurityManager s)

    If a security manager has already been established for the currently running Java application, a SecurityException is thrown. 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.

    Throws : SecurityException, if the security manager has already been set.

    Class Thread

    Thread is an important class that allows to run multiple program at a time. A thread is corresponds to a control of a program. 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 dæmon. 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 dæmon thread if and only if the creating thread is a dæmon. When a Java Virtual Machine starts up, there is usually a single non-dæmon 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:

    The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.

    All threads that are not dæmon threads have died, either by returning from the call to the run method or by performing the stop method. Let us see the various components that are available in this class.

    	public  class  java.lang.Thread
    					extends  java.lang.Object   
    		implements java.lang.Runnable   
    		 {
    				// 	Member elements
    			public final static int MAX_PRIORITY;	
    			//	MAX_PRIORITY = 10; The maximum priority that a thread can have. 
    			public final static int MIN_PRIORITY;	 
    			//	MIN_PRIORITY = 1 ;  The minimum priority that a thread can have.
    			public final static int NORM_PRIORITY;	 
    			//	NORM_PRIORITY = 5 ; The default priority that is assigned to a thread.
    
    				// 	Constructors
    			public Thread();	 
    			/*	Allocates a new Thread object. This constructor has the same effect as Thread(null, null, gname) where gname is a newly generated name. Automatically generated names are of the form "Thread-"+n where n is an integer.
    			*/
    			public Thread(Runnable  target);
    			/*	Allocates a new Thread object. This constructor has the same effect as Thread(null, target, gname), where gname is a newly generated name. Automatically generated names are of the form "Thread-"+n where n is an integer. Here, target  is the object whose run method is called.
    			*/
    			public Thread(Runnable  target, String  name);
    			//	Allocates a new Thread object. This constructor has the same effect as Thread(null, target, name). 
    			public Thread(String  name);	 
    			//	Allocates a new Thread object. This constructor has the same effect as Thread(null, null, name).
    			public Thread(ThreadGroup  group, Runnable  target);	
    			/*	Allocates a new Thread object. This constructor has the same effect as Thread(group, target, gname), where gname is a newly generated name. Automatically generated names are of the form "Thread-"+n where n is an integer.
    				Throws : SecurityException  if the current thread cannot create a thread in the specified thread group. 
    			*/
    			public Thread(ThreadGroup  group, Runnable  target, String  name);
    			/*	Allocates a new Thread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group. 
    				If group is not null, the checkAccess method of that thread group is called with no arguments; this may result in throwing a SecurityException; if group is null, the new process belongs to the same group as the thread this is created the new thread.
    				If the target argument is not null, the run method of the target is called when this thread is started. If the target argument is null, this thread's run method is called when this thread is started.
    				The priority of the newly created thread is set equal to the priority of the thread creating it, that is, the currently running thread. The method setPriority may be used to change the priority to a new value.
    				The newly created thread is a initially marked as being a dæmon thread if and only if the thread creating it is currently marked as a dæmon thread. The method setDaemon may be used to change whether or not a thread is a daemon. 
    				Throws :  SecurityException,  if the current thread cannot create a thread in the specified thread group.
    			*/
    			public Thread(ThreadGroup  group, String  name);	 
    			/*	Allocates a new Thread object. This constructor has the same effect as Thread(group, null, name). 
    				Throws :  SecurityException, if the current thread cannot create a thread in the specified thread group.
    			*/
    			
    			// 	Methods
    
    			public static int activeCount();	 
    			public void checkAccess();	 
    			public int countStackFrames();	 
    			public static Thread currentThread(); 
    			public void destroy();	 
    			public static void dumpStack();	 
    			public static int enumerate(Thread  tarray[]);	 
    			public final String getName();	 
    			public final int getPriority();	 
    			public final ThreadGroup getThreadGroup();	 
    			public void interrupt();	 
    			public static boolean interrupted();	 
    			public final boolean isAlive();	 
    			public final boolean isDaemon();	 
    			public boolean isInterrupted();	 
    			public final void join();	 
    			public final void  join(long  millis); 
    			public final void join(long  millis, int  nanos)	 
    			public final void resume();	 
    			public void run(); 
    			public final void setDaemon(boolean  on);	 
    			public final void setName(String  name);	 
    			public final void setPriority(int  newPriority);	 
    			public static void sleep(long  millis);	 
    			public static void sleep(long  millis, int  nanos)	 
    			public void start();	 
    			public final void stop();	 
    			public final void  stop(Throwable  obj); 
    			public final void suspend();	 
    			public String toString();	 
    			public static void yield(); 
    	}
    
    	Methods are described as in Table 2.19.
    

    Table 2.19

     

    Method

    Description

    activeCount()

    Returns : the current number of threads in this thread's thread group.

    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 method as its argument. This may result in throwing a security exception. 238

    Throws : SecurityException, if the current thread is not allowed to access the thread.

    countStackFrames()

    Counts the number of stack frames in this thread. The thread must be suspended. Returns : the number of stack frames in this thread.

    Throws : IllegalThreadStateException, if this thread is not suspended.

    currentThread()

    Find the currently executing thread.

    Returns : the currently executing thread.

    destroy()

    Destroys this thread, without any cleanup. Any monitors it has locked remain locked.

    dumpStack()

    Prints a stack trace of the current thread. Used only for debugging.

    enumerate(Thread tarray[])

    Copies into the array argument every thread in this thread's thread group. This method simple calls the enumerate method of this thread’s thread group withy the array argument.

    Returns : the number of threads put into the array.

    getName()

    Returns : this thread's name.

    getPriority()

    Returns : this thread's current priority.

    getThreadGroup()

    Returns : this thread's thread group.

    interrupt()

    Interrupts this thread.

    interrupted()

    Return : true if the current thread has been interrupted; false otherwise.

    isAlive()

    Determines if this thread is alive A thread is alive if it has been started and has not yet died. Returns : true if this thread is alive; false otherwise.

    isDaemon()

    Returns : true if this thread is a dæmon thread; false otherwise.

    isInterrupted()

    Returns :true if this thread has been interrupted; false otherwise.

    join()

    Waits for this thread to die.

    Throw : InterruptedException, another thread has interrupted the current thread.

    join(long millis)

    Waits at most millis milliseconds for for this thread to die. A timeout of 0 means to wait forever.

    Throws : InterruptedException, another thread has interrupted the current thread.

    join(long millis, int nanos)

    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die.

    Throws : InterruptedException, another thread has interrupted the current thread.

    resume()

    Resumes a suspended thread. First, the checkAccess method of this thread is called with no arguments. this may result in throwing a security exception (in the current thread). If the thread is alive but suspended. it is resumed and is permitted to make progress in its execution.

    Throws : SecurityException, if the current thread cannot modify this thread.

    run()

    If this thread was constructed using a separate Runnable run object , then that Runnable object’s run method is called. Otherwise, this method does nothing and rteturns. Subclasses of Thread should override this method.

    setDaemon(boolean on)

    Marks this thread as either a dæmon thread or a user thread. The Java Virtual Machine exits when the only threads running are all dæmon threads. This method must be called before the thread is started.239239

    Throws : IllegalThreadStateException, if this thread is active.

    setName(String name)

    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 security exception.

    Throws : SecurityException, if the current thread cannot modify this thread.

    setPriority(int newPriority)

    Changes the priority of this thread. First the checkAccess method of this thread is called with no arguments. This may result in throwing a security exception. 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.

    Throws : IllegalArgumentException, if the priority is not in the range MIN_PRIORITY to MAX_PRIORITY. Also can Throws : SecurityException, if the current thread cannot modify this thread.

    sleep(long millis)

    Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. The thread does not lose ownership of any monitors.

    Throws : InterruptedException, another thread has interrupted this thread.

    sleep(long millis, int nanos)

    Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. The thread does not lose ownership of any monitors.

    Throws : InterruptedException, another thread has interrupted this thread.

    start()

    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread. The result is that two threads are running concurrently: the current thread (which returns from the call to the start method) and the other thread (which executes its run method).

    Throws IllegalThreadStateException , if the thread was already started.

    stop()

    Forces this thread to stop executing. First, the checkAccess method of this thread is called with no arguments. This may result in throwing a security exception (in the current thread). The thread represented by the 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 will cause finally clauses of try statements to be executed before the thread officially dies). If a catch clause does catch 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 current uncaught exception is an instance of ThreadDepth.

    Throws : SecurityException, if the current thread cannot modify this thread.

    suspend()

    Suspends this thread. First, the checkAccess method of this thread is called with no arguments. This may result in throwing a security exception (in the current thread). If the thread is alive, it is suspended and makes no further progress unless and until it is resumed.

    Throws : SecurityException , if the current thread cannot modify this thread.

    toString()

    Returns : a string representation of this thread.

    yield()

    Causes the currently executing thread object to temporarily pause and allow other threads to execute.

    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.

    	public  class  java.lang.ThreadGroup
    						extends  java.lang.Object  
    	{
    			// 	Constructors
    		public ThreadGroup(String  name);
    		//	Constructs a new thread group, whose parent is the thread group of the currently running thread. 	 
    		public ThreadGroup(ThreadGroup  parent, String  name);   
    		/*	Creates a new thread group whose parent is the specified thread group. Throws :  NullPointerException,  if the thread group argument is null. and also SecurityException, if the current thread cannot create a thread in the specified thread group.
    		*/
    			// 	Methods
    		public int activeCount();	 
    		public int activeGroupCount();	 
    		public final void checkAccess(); 
    		public final void destroy();	 
    		public int enumerate(Thread  list[]);	 
    		public int enumerate(Thread  list[], boolean  recurse);	 
    		public int enumerate(ThreadGroup  list[]);	 
    		public int enumerate(ThreadGroup  list[], boolean  recurse);  
    		public final int getMaxPriority();
    		public final String getName();	 
    		public final ThreadGroup getParent();	 
    		public final boolean isDaemon();	 
    		public void list();	 
    		public final boolean parentOf(ThreadGroup  g);	 
    		public final void resume();	 
    		public final void setDaemon(boolean  daemon);	 
    		public final void  setMaxPriority(int  pri);	 
    		public final void stop(); 
    		public final void suspend();	 
    		public String toString(); 
    		public void uncaughtException(Thread  t, Throwable  e);   
    	}
    
    	Methods are stated in Table 2.20.
    

    Table 2.20

     

    Method

    Description

    activeCount()

    Returns : the number of active threads in this thread group and in any other thread group that has this thread group as an ancestor.

    activeGroupCount()

    Returns : the number of active thread groups with this thread group as an ancestor.

    checkAccess()

    Determines if the currently running thread has permission to modify this thread group. If there is a security manager, its checkAccess method is called withn this thread group as its argument. This may result in throwing a security exception.

    Throws : SecurityException, if the current thread is not allowed to access this thread group.

    destroy()

    Destroys this thread group and all of its sub-groups. This thread group must be empty, indicating that all threads that had been in this thread group have since stopped. Throws : IllegalThreadStateException, if the thread group is not empty or if the thread group has already destroyed. Also Throws : SecurityException, if the current thread cannot modify this thread group.

    enumerate(Thread list[])

    Copies into the specified array every active thread in this thread group and its sub-groups. An application should use the activeCount method to get an estimate of how big the array should be. If the array is too short to hold all the threads, the extra threads are silently ignored.243

    Returns : the number of threads put into the array.

    enumerate(Thread list[], boolean recurse)

    Copies into the specified array every active thread in this thread group. If the recurse flag is true references to every active thread in this thread's sub- groups are also included. If the array is too short to hold all the threads, the extra threads are silently ignored. An application should use the activeCount method to get an estimate of how big the array should be.

    Returns : the number of threads placed into the array.

    enumerate(ThreadGroup list[])

    Copies into the specified array references to every active sub-group in this thread group. An application should use the activeGroupCount method to get an estimate of how big the array should be. If the array is too short to hold all the threads, the extra threads are silently ignored.

    Returns : the number of thread groups put into the array.

    enumerate(ThreadGroup list[], boolean recurse)

    Copies into the specified array references to every active sub-group in this thread group. If the recurse flag is true references to every active, all sub- thread groups of the sub-thread groups and so forth are also included. An application should use the activeGroupCount method to get an estimate of how big the array should be.

    Returns : the number of thread groups put into the array.

    getMaxPriority()

    Returns :the maximum priority that a thread in this thread group can have.

    getName()

    Returns : the name of this thread group.

    getParent()

    Returns : the parent of this thread group. The top-level thread group is the only thread group whose parent is null.

    isDaemon()

    Determines if this thread group is a dæmon thread group. A dæmon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed.

    Returns: true if this thread group is a dæmon thread group; false otherwise.

    list()

    Prints information about this thread group to the standard output. This method is useful only for debugging.

    parentOf(ThreadGroup g)

    Determines if this thread group is either the thread group argument or one of its ancestor thread groups. Returns : true if this thread group is the thread group argument or one of its ancestor thread groups; false otherwise.

    resume()

    Resumes all processes 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 resume method on all the threads in this thread group and in all of its sub-thread groups.

    Throws : SecurityException, if the current thread is not allowed to access this thread group or any of the threads in the thread group.

    setDaemon(boolean daemon)

    Sets whether this thread group is a dæmon thread group. First, the checkAccess method of this thread group is called with no arguments; this may result in a security exceptiion. Marks whether this thread is a dæmon thread group. A dæmon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed.

    Throws : SecurityException, if the current thread cannot modify this thread.

    setMaxPriority(int pri)

    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 exceptiion. Threads in the thread group that already have a higher priority are not affected.

    Throws : SecurityException, if the current thread cannot modify this thread group.

    stop()

    Stops all processes in this thread group. First, the checkAccess method of this thread group is called with no arguments; this may result in a security exceptiion. This method then calls the stop method on all the threads in this thread group and in all of its sub-thread groups.

    Throws : SecurityException, if the current thread is not allowed to access this thread group or any of the threads in the thread group.

    suspend()

    Suspends all processes 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 suspend method on all the threads in this thread group and in all of its sub-thread groups.

    Throws : SecurityException, if the current thread is not allowed to access this thread group or any of the threads in the thread group.

    toString()

    Returns : a string representation of this thread group.

    uncaughtException(Thread t, Throwable e)

    The Java Virtual Machine calls this method when a thread in this thread group stops because of an uncaught exception. The uncaughtException method of ThreadGroup does the following :

  • If this thread group has a parent thread group, the uncaughtException method of that parent is called with the same two arguments.

  • Otherwise, this method determines if the Throwable argument is an instance of ThreadDeath. if so, nothing dspecial is done. Otherwise, the Throwable’s printStackTrack method is called to print a stack back trace to the standard error stream.

    Applications can override this method in subclasses of ThreadGroup to provide alternative handling of uncaught exceptions.

  • 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. A Throwable 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.

    	
    	public  class  java.lang.Throwable
    					extends  java.lang.Object   
    	{
    			// 	Constructors
    		public Throwable();	 
    		//	Constructs a new Throwable with no detail message. The stack trace is automatically filled in.
    		public Throwable(String  message);
    		//	Constructs a new Throwable with the specified detail message. The stack trace is automatically filled in. 	 
    			// 	Methods
    		public Throwable fillInStackTrace();	 
    		public String getMessage();	 
    		public void printStackTrace();	 
    		public void printStackTrace(PrintStream  s);	 
    		public String toString();	 
    	}
    	Methods are described in Table 2.21.
    

    Table 2.21


    Method

    Description

    fillInStackTrace()

    Fills in the execution stack trace. This method is useful when an application is re-throwing an error or exception. For example:

    try {
    a = b / c;
    } catch(ArithmeticThrowable e) {
    a = Number.MAX_VALUE;
    throw e.fillInStackTrace();
    }

    getMessage()

    Returns : the detail message of this Throwable, or null if this Throwable does not have a detailed message.

    printStackTrace()

    Prints this Throwable and its backtrace to the standard error output stream.

    printStackTrace(PrintStream s)

    Prints this Throwable and its backtrace to the specified print stream.

    toString()

    Returns : a string representation of this Throwable.

    Interface Cloneable

    A class implements the Cloneable interface to indicate to the clone method in class Object 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.

    public interface java.lang.Cloneable { }

    Interface 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.

    	public  interface  java.lang.Runnable
    	{
            	// 	Methods
        	public abstract void run();	
    		/*	When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
    		*/ 
    	}
    

    Class ArithmeticException

    Thrown when an exceptional arithmetic condition has occurred. For example, an integer "divide by zero" throws an instance of this class.

    	public  class  java.lang.ArithmeticException
    					extends  java.lang.RuntimeException   
    	{	
    			// 	Constructors
    		public ArithmeticException();
    		//	Constructs an ArithmeticException with no detail message.
    	 
    		public ArithmeticException(String  s);	
    		//	Constructs an ArithmeticException with the specified detail message. 
    	}
    

    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.

    	public  class  java.lang.ArrayIndexOutOfBoundsException
    					extends  java.lang.IndexOutOfBoundsException   
    	{	
    			// 	Constructors
    		public ArrayIndexOutOfBoundsException();	 
    		//	Constructs an ArrayIndexOutOfBoundsException with no detail message.
    		public ArrayIndexOutOfBoundsException(int  index);
    	   /* Constructs a new ArrayIndexOutOfBoundsException class with an argument indicating the illegal index.*/ 
    		public ArrayIndexOutOfBoundsException(String  s);	
    		/*	Constructs a ArrayIndexOutOfBoundsException with the specified detail	message.*/ 
    	}
    

    Class ArrayStoreException

    Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects.

    	public  class  java.lang.ArrayStoreException
    					extends  java.lang.RuntimeException   
    	{
    			// 	Constructors
    		public ArrayStoreException(); 
    		//	Constructs a ArrayStoreException with no detail message.
    
    		public ArrayStoreException(String  s);	
    		//	Constructs a ArrayStoreException with the specified detail message. 
    	}
    

    Class ClassCastException

    Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.

    	public  class  java.lang.ClassCastException
        				extends  java.lang.RuntimeException  
    	{
            	// 	Constructors
        	public ClassCastException();
    		//	Constructs a ClassCastException with no detail message. 
    	public ClassCastException(String  s);	
    		//	Constructs a ClassCastException with the specified detail message. 
    	}
    
    Class ClassNotFoundException

    Thrown when an application tries to load in a class through its string name using any one of the following, but no definition for the class with the specifed name could be found.

  • the forName method in class Class
  • the findSystemClass method in class ClassLoader
  • the loadClass method in class ClassLoader
    	public  class  java.lang.ClassNotFoundException
    						extends  java.lang.Exception   
    		{
    				// 	Constructors
    		public ClassNotFoundException();	 
    			//	Constructs a ClassNotFoundException with no detail message.
    		public ClassNotFoundException(String  s);
    			//	Constructs a ClassNotFoundException with the specified detail message. 	 	}
    

    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 clonable interface. Applications that override the clone method can also throw this exception to indicate that an object could not or should not be cloned.
    		
    	public  class  java.lang.CloneNotSupportedException
    						extends  java.lang.Exception  
    		{
    				// 	Constructors
    		public CloneNotSupportedException();
    			//	Constructs a CloneNotSupportedException with no detail message.
    		 
    		public CloneNotSupportedException(String  s);	 
    			//	Constructs a CloneNotSupportedException with the specified detail message.
    		}
    

    Class Exception

    The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.

    	public  class  java.lang.Exception
    					extends  java.lang.Throwable   
    		{
    				// 	Constructors
    		public Exception();	 
    			//	Constructs an Exception with no specified detail message.
    		public Exception(String  s);	
    			//	Constructs a Exception with the specified detail message. 
    		}
    

    Class IllegalAccessException

    Thrown when an application tries to load in a class through its string name using any one of the following, 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 :

  • the forName method
  • the findSystemClass method in class ClassLoader
  • the loadClass method in class ClassLoader 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.
    	public  class  java.lang.IllegalAccessException
    					extends  java.lang.Exception  
    	{
    			// 	Constructors
    		public IllegalAccessException();	
    		//	Constructs a IllegalAccessException without  any  message. 
    
    		public IllegalAccessException(String  s);	 
    		//	Constructs a IllegalAccessException with a detail message.
    	}
    

    Class IllegalArgumentException

    Thrown to indicate that a method has been passed an illegal or inappropriate argument.

    	public  class  java.lang.IllegalArgumentException
    						extends  java.lang.RuntimeException  
    		{
    				// 	Constructors
    		public IllegalArgumentException();	 
    			//	Constructs an IllegalArgumentException with no detail message.
    
    		public IllegalArgumentException(String  s);
    			//	Constructs an IllegalArgumentException with the specified detail message.
    		 
    		}
    

    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.

    	public  class  java.lang.IllegalMonitorStateException
    					extends  java.lang.RuntimeException   
    	{	
    			// 	Constructors
    		public IllegalMonitorStateException();	
    		//	Constructs an IllegalMonitorStateException with no detail message.
    		public IllegalMonitorStateException(String  s);	 
    		/*	Constructs an IllegalMonitorStateException with the specified detail message.
    		*/
    	}
    

    Class IllegalThreadStateException

    Thrown to indicate that a thread is not in an appropriate state for the requested operation.

    	public  class  java.lang.IllegalThreadStateException
        				extends  java.lang.IllegalArgumentException   
    	{
            	// 	Constructors
        	public IllegalThreadStateException();	
    		//	Constructs an IllegalThreadStateException with no detail message.
     
        	public IllegalThreadStateException(String  s); 
    		//	Constructs an IllegalThreadStateException with the specified detail message.
    	}
    

    Class IndexOutOfBoundsException

    Instances of this class are thrown 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.

    	
    	public  class  java.lang.IndexOutOfBoundsException
        					extends  java.lang.RuntimeException   
    	{
            	// 	Constructors
        	public IndexOutOfBoundsException();
    		//	Constructs an IndexOutOfBoundsException with no detail message. 	
     
        	public IndexOutOfBoundsException(String  s);	
    		//	Constructs an IndexOutOfBoundsException with the specified detail message. 
    	}
     

    Class InstantiationException

    Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the the specified class object cannot be instantiated because it is an interface or is an abstract class.

    	public  class  java.lang.InstantiationException
    					extends  java.lang.Exception   
    	{
    			// 	Constructors
    		public InstantiationException();
    		//	Constructs an InstantiationException with no detail message.
    		public InstantiationException(String  s);	 
    		//	Constructs an InstantiationException with the specified detail message.
    	}
    

    Class InterruptedException

    Thrown when a thread is waiting, sleeping. or otherwise paused for a long time and another thread interrupts it using the the interrupt method in class Thread.

    	public  class  java.lang.InterruptedException
    					extends  java.lang.Exception  
    	{
    			// 	Constructors
    		public InterruptedException();
    		//	Constructs an InterruptedException with no detail message.
    		public InterruptedException(String  s);
    		//	Constructs an InterruptedException with the specified detail message. 
    	}
    

    Class NegativeArraySizeException

    Thrown if an application tries to create an array with negative size.

    	
    	public  class  java.lang.NegativeArraySizeException
        				extends  java.lang.RuntimeException   
    	{
            	// 	Constructors
        	public NegativeArraySizeException();
    		//	Constructs a NegativeArraySizeException with no detail message. 
    	 
        	public NegativeArraySizeException(String  s);	 
    		//	Constructs a NegativeArraySizeException with the specified detail message.
    	}
    

    Class NoSuchMethodException

    Thrown hen there is no succh method exist.

    	public  class  java.lang.NoSuchMethodException
    					extends  java.lang.Exception  
    	{
    			// 	Constructors
    		public NoSuchMethodException(); 
    		//	Constructs a NoSuchMethodException without a detail message.
    
    		public NoSuchMethodException(String  s);
    		//	Constructs a NoSuchMethodException with a detail message. 	 
    	}
    

    Class NullPointerException

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

  • Call the instance method of a null object.
  • Accessing or modifying the field of the null object.
  • Taking the length of null as if it were an array.
  • Accessing or modifying the slots of null as if it were an array.
  • Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object.
    	
    	public  class  java.lang.NullPointerException
    					extends  java.lang.RuntimeExceptio  
    	{
    			// 	Constructors
    		public NullPointerException();
    		//	Constructs a NullPointerException with no detail message.
    		public NullPointerException(String  s); 
    		//	Constructs a NullPointerException with the specified detail message. 	
    	}
    

    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.

    	public  class  java.lang.NumberFormatException
        				extends  java.lang.IllegalArgumentException   
    	{
            	// 	Constructors
    		public NumberFormatException(); 
    		//	Constructs a NumberFormatException with no detail message.
    
    		public NumberFormatException(String  s);	
    		//	Constructs a NumberFormatException with the specified detail message. 
    	}
    

    Class RuntimeException

    RuntimeException is the superclass of those exceptions which 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.

    	
    	public  class  java.lang.RuntimeException
    					extends  java.lang.Exception  
    	{
    			// 	Constructors
    		public RuntimeException(); 
    		//	Constructs a RuntimeException with no detail message.
    		public RuntimeException(String  s);
    		//	Constructs a RuntimeException with the specified detail message. 	 
    	}
    

    Class SecurityException

    Thrown by the security manager to indicate a security violation.

    	public  class  java.lang.SecurityException
    					extends  java.lang.RuntimeException   
    	{
    		// 	Constructors
    		public SecurityException();	 
    		//	Constructs a SecurityException with no detail message.
    		public SecurityException(String  s);
    		//	Constructs a SecurityException with the specified detail message. 	 
    	}
    

    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.

    	public  class  java.lang.StringIndexOutOfBoundsException
    				extends  java.lang.IndexOutOfBoundsException   
    	{
    			// 	Constructors
    		public StringIndexOutOfBoundsException();	 
    		//	Constructs a StringIndexOutOfBoundsException with no detail message.
    		public StringIndexOutOfBoundsException(int  index);	
    		/*	Constructs a new StringIndexOutOfBoundsException class with an argument indicating  the illegal index.
    		*/
    		public StringIndexOutOfBoundsException(String  s)
    		/*	Constructs a StringIndexOutOfBoundsException with the specified detail 	message. 
    		*/		 
    	}
    

    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 runtime if the definition of some class has incompatibably changed since the currently executing method was last compiled.

    	public  class  java.lang.AbstractMethodError
        				extends  java.lang.IncompatibleClassChangeError 
     	{
            	// 	Constructors
        	public AbstractMethodError();
    		//	Constructs an AbstractMethodError with no detail message.
     	
        	public AbstractMethodError(String  s);
     		//	Constructs an AbstractMethodError with the specified detail message.
    	}
    

    Class ClassCircularityError

        public  class  java.lang.ClassCircularityError
        				extends  java.lang.LinkageError 
     	{
           	// 	Constructors
        	public ClassCircularityError();
    		//	Constructs a ClassCircularityError with no detail message.
     	
        	public ClassCircularityError(String  s);
    		//	Constructs a ClassCircularityError with the specified detail message.
    	}
    

    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.

    	public  class  java.lang.ClassFormatError
    					extends  java.lang.LinkageError  
    	{ 
    			// 	Constructors
    		public ClassFormatError();
    		//	Constructs a ClassFormatError with no detail message.
    
    	   public ClassFormatError(String  s);	
    		//	Constructs a ClassFormatError with the specified detail message.
    	}
    

    Class Error

    Thrown due to some abnormal conditions.

    	public  class  java.lang.Error
        				extends  java.lang.Throwable  
     	{
            	// 	Constructors
    		public Error();
    		//	Constructs an Error with no specified detail message.
    
    		public Error(String  s);	
    		//	Constructs an Error with the specified detail message.
    	}
    

    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 runtime if the definition of a class has incompatibably changed.

    	public  class  java.lang.IllegalAccessError
    					extends  java.lang.IncompatibleClassChangeError  
    	{
    			// 	Constructors
    	   public IllegalAccessError(); 
    		//	Constructs an IllegalAccessError with no detail message.
    
    	   public IllegalAccessError(String  s);	 
    		//	Constructs an IllegalAccessError with the specified detail message.
    	}
    

    Class IncompatibleClassChangeError

    An instance of a subclass of IncompatibleClassChangeError is thrown to indicate that an incompatible class change has occurred to some class definition. The definition of some class, upon which the currently executing method depends, has since changed.

    	public  class  java.lang.IncompatibleClassChangeError
        				extends  java.lang.LinkageError  
    	{
            	// 	Constructors
        	public IncompatibleClassChangeError();	
    		//	Constructs an IncompatibleClassChangeError with no detail message.
    
     
        	public IncompatibleClassChangeError(String  s);	 
    		//	Constructs an IncompatibleClassChangeError with the specified detail message.
    	}
    

    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 runtime if the definition of a class has incompatibably changed.

    	public  class  java.lang.InstantiationError
        				extends  java.lang.IncompatibleClassChangeError  
    	{
            	// 	Constructors
        	public InstantiationError(); 
    		//	Constructs an InstantiationError with no detail message.
     	
        	public InstantiationError(String  s);
    		//	Constructs an InstantiationError with the specified detail message. 	 
    	}
    

    Class InternalError

    Thrown to indicate some unexpected internal error has occurred in the Java Virtual Machine.

    	public  class  java.lang.InternalError
        			extends  java.lang.VirtualMachineError   
    	{
            	// 	Constructors
        	public InternalError();	
    		//	Constructs an InternalError with no detail message.
     
        	public InternalError(String  s); 
    		//	Constructs an InternalError with the specified detail message.
    	}
    

    Class LinkageError

    LinkageError indicate that a class has some dependency on another class.

    	public  class  java.lang.LinkageError
        				extends  java.lang.Error   
    	{
            	// 	Constructors
        	public LinkageError();	
    		//	Constructs a LinkageError with no detail message.
     
        	public LinkageError(String  s);	 
    		//	Constructs a LinkageError with the specified detail message.
    	}
    

    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.

    	public  class  java.lang.NoClassDefFoundError
        				extends  java.lang.LinkageError   
    	{
            	// 	Constructors
        	public NoClassDefFoundError();	
    		//	Constructs a NoClassDefFoundError with no detail message.
     
        	public NoClassDefFoundError(String  s);
    		//	Constructs a NoClassDefFoundError with the specified detail message. 	 
    	}
    

    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 runtime if the definition of a class has incompatibably changed.

    	public  class  java.lang.NoSuchFieldError
        				extends  java.lang.IncompatibleClassChangeError   
    	{		
            	// 	Constructors
    		public NoSuchFieldError(); 
    		//	Constructs a NoSuchFieldException with no detail message.
    
    		public NoSuchFieldError(String  s);
    		//	Constructs a NoSuchFieldException with the specified 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.

    	public  class  java.lang.NoSuchMethodError
        				extends  java.lang.IncompatibleClassChangeError  
    	{
            	// 	Constructors
        	public NoSuchMethodError(); 
    		//	Constructs a NoSuchMethodException with no detail message.
    
    	   public NoSuchMethodError(String  s);
    		//	Constructs a NoSuchMethodException with the specified detail message. 
    	}
    

    Class OutOfMemoryError

    Thrown when the Java Virtual Machine is out of cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

        public  class  java.lang.OutOfMemoryError
        				extends  java.lang.VirtualMachineError  
    	{
            	// 	Constructors
    	public OutOfMemoryError();	
    		//	Constructs an OutOfMemoryError with no detail message.
    
    	public OutOfMemoryError(String  s); 
    		//	Constructs an OutOfMemoryError with the specified detail message.
    	}
    

    Class StackOverflowError

    Thrown when a stack overflow occurs because an application recurses too deeply.

    	public  class  java.lang.StackOverflowError
        				extends  java.lang.VirtualMachineError  
    	{
            	// 	Constructors
        	public StackOverflowError();	
    		//	Constructs a StackOverflowError with no detail message.
     
        	public StackOverflowError(String  s);	
    		//	Constructs a StackOverflowError with the specified detail message. 
    	}
    

    Class ThreadDeath

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

    	public  class  java.lang.ThreadDeath
        				extends  java.lang.Error   
    	{
            	// 	Constructors
    	   public ThreadDeath();	
    		//	Constructs a new thread death object. 
    	}
    

    Class UnknownError

    Thrown when an unknown but serious exception has occurred in the Java Virtual Machine.

    	public  class  java.lang.UnknownError
        				extends  java.lang.VirtualMachineError   
    	{
            	// 	Constructors
    		public UnknownError();	 
    			//	Constructs an UnknownError with no detail message.
    
    		public UnknownError(String  s); 
    			//	Constructs an UnknownError with the specified detail message.
    	}
    

    Class UnsatisfiedLinkError

    Thrown if the The Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.

    
    	public  class  java.lang.UnsatisfiedLinkError
    					extends  java.lang.LinkageError  
    	{	
    			// 	Constructors
    	public UnsatisfiedLinkError();	
    		//	Constructs an UnsatisfiedLinkError with no detail message.
     
    	public UnsatisfiedLinkError(String  s);	
    		//	Constructs an UnsatisfiedLinkError with the specified 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.

    	public  class  java.lang.VerifyError
    	    			extends  java.lang.LinkageError  
    	{
            	// 	Constructors
    		public VerifyError(); 
    			//	Constructs an VerifyError with no detail message.
    
    		public VerifyError(String  s);	
    			//	Constructs an VerifyError with the specified detail message. 
    	}
    

    Class VirtualMachineError

    Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.

    	public  class  java.lang.VirtualMachineError
        			extends  java.lang.Error   
    	{
            	// 	Constructors
        	public VirtualMachineError();
    		//	Constructs a VirtualMachineError with no detail message.
     	 
        	public VirtualMachineError(String  s);
    		//	Constructs a VirtualMachineError with the specified detail message. 	 
    	}