该方法将调用该方法的Number对象的值转换为从该方法返回的原始数据类型。
这是每种原始数据类型的单独方法-
byte byteValue() short shortValue() int intValue() long longValue() float floatValue() double doubleValue()
此方法返回签名中给定的原始数据类型。
public class Test { public static void main(String args[]) { Integer x=5; //返回字节原始数据类型 System.out.println( x.byteValue() ); //返回双原始数据类型 System.out.println(x.doubleValue()); //返回长原始数据类型 System.out.println( x.longValue() ); } }
这将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/java/number-xxxvalue.html
来源:LearnFk无涯教程网
5 5.0 5
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)