Chapter 32

Package java.lang


CONTENTS


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

Figure 32.1: Contents of package java.lang.

Table 32.1. Contents of the java.lang package.

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

Cloneable

Object

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

public interface java.lang.Cloneable {
}

Runnable

Object

See also: Thread

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

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

run

Runnable

public abstract void run()

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

Boolean

Object

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

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

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

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

Member Constants

public final static Boolean FALSE

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

public final static Boolean TRUE

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

Boolean

Boolean

public Boolean(boolean value)

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

value is the Boolean value to be wrapped.

Boolean

Boolean

public Boolean(String s)

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

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

booleanValue

Boolean

public boolean booleanValue()

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

The Boolean value represented.

equals

Boolean

public boolean equals(Object obj)

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

obj is the object to compare.

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

equals in class Object.

getBoolean

Boolean

public static boolean getBoolean(String name)

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

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

The Boolean value of the specified system property.

HashCode

Boolean

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

HashCode in class Object.

toString

Boolean

public String toString()

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

A string representing the Boolean value of this object.

toString in class Object.

valueOf

Boolean

public static Boolean valueOf(String s)

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

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

A Boolean wrapper object representing the specified string.

Character

Object

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

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

  // Constructors
  public Character(char value);

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

Member Constants

public final static int MAX_RADIX

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

public final static int MAX_VALUE

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

public final static int MIN_RADIX

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

public final static int MIN_VALUE

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

Character

Character

public Character(char value)

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

value is the character value to be wrapped.

charValue

Character

public char charValue()

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

The character value represented.

digit

Character

public static int digit(char ch, int radix)

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

ch is the character to be converted to a number.

radix is the radix to use in the conversion.

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

equals

Character

public boolean equals(Object obj)

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

obj is the object to compare.

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

equals in class Object.

forDigit

Character

public static char forDigit(int digit, int radix)

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

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

radix is the radix to use in the conversion.

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

hashCode

Character

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

isDefined

Character

public static boolean isDefined(char ch)

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

ch is the character to be checked.

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

isDigit

Character

public static boolean isDigit(char ch)

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

ch is the character to be checked.

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

isJavaLetter

Character

public static boolean isJavaLetter(char ch)

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

ch is the character to be checked.

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

isJavaLetterOrDigit

Character

public static boolean isJavaLetterOrDigit(char ch)

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

ch is the character to be checked.

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

isLetter

Character

public static boolean isLetter(char ch)

This method determines whether the specified character is a letter.

ch is the character to be checked.

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

isLetterOrDigit

Character

public static boolean isLetterOrDigit(char ch)

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

ch is the character to be checked.

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

isLowerCase

Character

public static boolean isLowerCase(char ch)

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

ch is the character to be checked.

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

isSpace

Character

public static boolean isSpace(char ch)

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

ch is the character to be checked.

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

isTitleCase

Character

public static boolean isTitleCase(char ch)

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

ch is the character to be checked.

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

isUpperCase

Character

public static boolean isUpperCase(char ch)

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

ch is the character to be checked.

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

toLowerCase

Character

public static char toLowerCase(char ch)

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

ch is the character to be converted.

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

toString

Character

public String toString()

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

A string representing the character value of this object.

toString in class Object.

toTitleCase

Character

public static char toTitleCase(char ch)

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

ch is the character to be converted.

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

toUpperCase

Character

public static char toUpperCase(char ch)

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

ch is the character to be converted.

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

Class

Object

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

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

forName

Class

public static Class forName(String className) throws ClassNotFoundException

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

className is the fully qualified name of the desired class.

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

ClassNotFoundException if the class could not be found.

getClassLoader

Class

public ClassLoader getClassLoader()

This method determines the class loader for this object.

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

getInterfaces

Class

public Class[] getInterfaces()

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

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

getName

Class

public String getName()

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

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

getSuperclass

Class

public Class getSuperclass()

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

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

isInterface

Class

public boolean isInterface()

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

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

newInstance

Class

public Object newInstance() throws InstantiationException, ÂIllegalAccessException

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

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

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

IllegalAccessException if the class is not accessible.

toString

Class

public String toString()

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

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

toString in class Object.

ClassLoader

Object

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

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

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

ClassLoader

ClassLoader

protected ClassLoader()

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

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

defineClass

ClassLoader

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

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

b is the byte array containing the class data.

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

len is the length in bytes of the class data.

A Class object created from the class data.

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

findSystemClass

ClassLoader

protected final Class findSystemClass(String name) throws ClassNotFoundException

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

name is the name of the system class to find.

A Class object representing the system class.

ClassNotFoundException if the class is not found.

NoClassDefFoundError if a definition for the class is not found.

loadClass

ClassLoader

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

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

name is the name of the desired class.

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

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

ClassNotFoundException if the class is not found.

resolveClass

ClassLoader

protected final void resolveClass(Class c)

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

c is the class to be resolved.

Compiler

Object

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

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

command

Compiler

public static Object command(Object any)

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

any is the object on which to perform an operation.

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

compileClass

Compiler

public static boolean compileClass(Class clazz)

This method compiles the specified class.

clazz is the class to compile.

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

compileClasses

Compiler

public static boolean compileClasses(String string)

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

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

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

Disable

Compiler

public static void disable()

This method disables the compiler.

Enable

Compiler

public static void enable()

This method enables the compiler.

Double

Number

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

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

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

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

Member Constants

public final static double MAX_VALUE

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

public final static double MIN_VALUE

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

public final static double NaN

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

public final static double NEGATIVE_INFINITY

This is a constant representing negative infinity for double types.

public final static double POSITIVE_INFINITY

This is a constant representing positive infinity for double types.

Double

Double

public Double(double value)

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

value is the double value to be wrapped.

Double

Double

public Double(String s) throws NumberFormatException

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

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

NumberFormatException if the string does not contain a parsable double.

DoubleToLongBits

Double

public static long doubleToLongBits(double value)

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

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

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

doubleValue

Double

public double doubleValue()

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

The double value represented.

doubleValue in class Number.

equals

Double

public boolean equals(Object obj)

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

obj is the object to compare.

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

equals in class Object.

floatValue

Double

public float floatValue()

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

A float conversion of the double value represented.

floatValue in class Number.

hashCode

Double

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

intValue

Double

public int intValue()

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

An integer conversion of the double value represented.

intValue in class Number.

isInfinite

Double

public boolean isInfinite()

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

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

isInfinite

Double

public static boolean isInfinite(double v)

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

v is the double value to be checked.

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

isNaN

Double

public boolean isNaN()

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

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

isNaN

Double

public static boolean isNaN(double v)

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

v is the double value to be checked.

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

LongBitsToDouble

Double

public static double longBitsToDouble(long bits)

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

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

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

longValue

Double

public long longValue()

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

A long conversion of the double value represented.

longValue in class Number.

toString

Double

public String toString()

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

A string representing the double value of this object.

toString in class Object.

toString

Double

public static String toString(double d)

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

d is the double value to be converted.

A string representing the specified double value.

valueOf

Double

public static Double valueOf(String s) throws NumberFormatException

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

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

A double wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable double.

Float

Number

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

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

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

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

Member Constants

public final static float MAX_VALUE

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

public final static float MIN_VALUE

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

public final static float NaN

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

public final static float NEGATIVE_INFINITY

This is a constant representing negative infinity for float types.

public final static float POSITIVE_INFINITY

This is a constant representing positive infinity for float types.

Float

Float

public Float(double value)

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

value is the double value to be wrapped.

Float

Float

public Float(float value)

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

value is the float value to be wrapped.

Float

Float

public Float(String s) throws NumberFormatException

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

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

NumberFormatException if the string does not contain a parsable float.

doubleValue

Float

public double doubleValue()

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

A double conversion of the float value represented.

doubleValue in class Number.

equals

Float

public boolean equals(Object obj)

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

obj is the object to compare.

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

equals in class Object.

FloatToIntBits

Float

public static int floatToIntBits(float value)

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

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

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

floatValue

Float

public float floatValue()

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

The float value represented.

floatValue in class Number.

hashCode

Float

public int hashCode()

This method calculates a hash code for this object.

A hash code for this object.

hashCode in class Object.

IntBitsToFloat

Float

public static float intBitsToFloat(int bits)

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

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

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

intValue

Float

public int intValue()

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

An integer conversion of the float value represented.

intValue in class Number.

isInfinite

Float

public boolean isInfinite()

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

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

isInfinite

Float

public static boolean isInfinite(float v)

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

v is the float value to be checked.

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

isNaN

Float

public boolean isNaN()

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

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

isNaN

Float

public static boolean isNaN(float v)

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

v is the float value to be checked.

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

longValue

Float

public long longValue()

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

A long conversion of the float value represented.

longValue in class Number.

toString

Float

public String toString()

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

A string representing the float value of this object.

toString in class Object.

toString

Float

public static String toString(float f)

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

f is the float value to be converted.

A string representing the specified float value.

valueOf

Float

public static Float valueOf(String s) throws NumberFormatException

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

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

A float wrapper object representing the specified string.

NumberFormatException if the string does not contain a parsable float.

Integer

Number

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

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

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

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

Member Constants

public final static int MAX_VALUE

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

public final static int MIN_VALUE

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

Integer

Integer

public Integer(int value)

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

value is the integer value to be wrapped.

Integer

Integer

public Integer(String s) throws NumberFormatException

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

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

NumberFormatException if the string does not contain a parsable integer.

doubleValue

Integer

public double doubleValue()

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

A double convers