Java xxxValue() 方法
Java 教程
· 2019-02-08 09:59:01
xxxValue() 方法用于将 Number 对象转换为 xxx 数据类型的值并返回。
相关的方法有:
| 类型 | 方法及描述 |
|---|---|
| byte | byteValue() : 以 byte 形式返回指定的数值。 |
| abstract double | doubleValue() : 以 double 形式返回指定的数值。 |
| abstract float | floatValue() : 以 float 形式返回指定的数值。 |
| abstract int | intValue() : 以 int 形式返回指定的数值。 |
| abstract long | longValue() : 以 long 形式返回指定的数值。 |
| short | shortValue() : 以 short 形式返回指定的数值。 |
参数
以上各函数不接受任何的参数。
返回值
转换为 xxx 类型后该对象表示的数值。
实例
Test.java 文件
public class Test{
public static void main(String args[]){
Integer x = 5;
// 返回 byte 原生数据类型
System.out.println( x.byteValue() );
// 返回 double 原生数据类型
System.out.println(x.doubleValue());
// 返回 long 原生数据类型
System.out.println( x.longValue() );
}
}
编译以上程序,输出结果为:
5 5.0 5
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
Python Algorithms
Magnus Lie Hetland / Apress / 2010-11-24 / USD 49.99
Python Algorithms explains the Python approach to algorithm analysis and design. Written by Magnus Lie Hetland, author of Beginning Python, this book is sharply focused on classical algorithms, but it......一起来看看 《Python Algorithms》 这本书的介绍吧!