Contents | Prev | Next | Index

20.6 The Class java.lang.Number

The abstract class Number has subclasses Integer, Long, Float, and Double which wrap primitive types, defining abstract methods to convert the represented numeric value to int, long, float, and double.

public abstract class Number {
	public abstract int intValue();
	public abstract long longValue();
	public abstract float floatValue();
	public abstract double doubleValue();
}

20.6.1 public abstract int intValue()

The general contract of the intValue method is that it returns the numeric value represented by this Number object after converting it to type int.

Overridden by Integer (§20.7.8), Long (§20.8.8), Float (§20.9.12), and Double (§20.10.11).

20.6.2 public abstract long longValue()

The general contract of the longValue method is that it returns the numeric value represented by this Number object after converting it to type long.

Overridden by Integer (§20.7.9), Long (§20.8.9), Float (§20.9.13), and Double (§20.10.12).

20.6.3 public abstract float floatValue()

The general contract of the floatValue method is that it returns the numeric value represented by this Number object after converting it to type float.

Overridden by Integer (§20.7.10), Long (§20.8.10), Float (§20.9.14), and Double (§20.10.13).

20.6.4 public abstract double doubleValue()

The general contract of the doubleValue method is that it returns the numeric value represented by this Number object after converting it to type double.

Overridden by Integer (§20.7.11), Long (§20.8.11), Float (§20.9.15), and Double (§20.10.14).


Contents | Prev | Next | Index

Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to [email protected]