- java.lang.Object
-
- java.lang.Number
-
- All Implemented Interfaces:
-
Serializable
- 已知直接子类:
-
AtomicInteger,AtomicLong,BigDecimal,BigInteger,Byte,Double,DoubleAccumulator,DoubleAdder,Float,Integer,Long,LongAccumulator,LongAdder,Short
public abstract class Number extends Object implements Serializable
抽象类Number是表示数字值可转换为基本数据类型平台类的超类byte,double,float,int,long,和short。 从特定的Number实现的数值到给定的基元类型的转换的具体语义由所Number实现定义。 对于平台类,转换通常类似于The Java™ Language Specification中定义的缩小原语转换或扩展原语转换,用于在原始类型之间进行转换。 因此,转换可能会丢失有关数值的总体大小的信息,可能会失去精度,甚至可能会返回与输入不同的符号结果。 有关转换详情,请参阅给定的Number实现的文档。- 从以下版本开始:
- 1.0
- 另请参见:
- Serialized Form
- See The Java™ Language Specification:
- 5.1.2扩大原始转换,5.1.3缩小原始转换
-
-
构造方法摘要
构造方法 Constructor 描述 Number()
-
方法摘要
所有方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 bytebyteValue()返回指定数字的值作为byte。abstract doubledoubleValue()返回指定数字的值作为double。abstract floatfloatValue()返回指定数字的值作为float。abstract intintValue()返回指定数字的值作为int。abstract longlongValue()返回指定数字的值作为long。shortshortValue()返回指定数字的值作为short。
-
-
-
方法详细信息
-
intValue
public abstract int intValue()
返回指定数字的值作为int。- 结果
-
该对象在转换为
int之后表示的数值。
-
longValue
public abstract long longValue()
返回指定数字的值作为long。- 结果
-
该对象在转换为
long之后表示的数值。
-
floatValue
public abstract float floatValue()
返回指定数字的值作为float。- 结果
-
该对象在转换为
float之后表示的数值。
-
doubleValue
public abstract double doubleValue()
返回指定数字的值作为double。- 结果
-
该对象在转换为
double之后表示的数值。
-
byteValue
public byte byteValue()
返回指定数字的值作为byte。此实现将
intValue()的结果返回给一个byte。- 结果
-
该对象在转换为
byte之后表示的数值。 - 从以下版本开始:
- 1.1
-
shortValue
public short shortValue()
返回指定数字的值作为short。此实现将
intValue()的结果返回给一个short。- 结果
-
该对象在转换为
short之后表示的数值。 - 从以下版本开始:
- 1.1
-
-