Java intValue()方法
intValue()方法
Java Number包装类中的intValue()方法,可将继承自Number类的类对象,比如Byte、Short、Long、Double、Float等对象,转换为int类型的数值,包括int的包装类Integer。其语法如下:
NumberObj.intValue()
intValue()方法实例代码
public class test {
public static void main(String[] args) {
Integer a = 2;
int x = a.intValue();
Double b = 6.5;
int y = b.intValue();
Long c = 3L;
int z = c.intValue();
Short d = 9;
int n = d.intValue();
System.out.println("x="+x+",y="+y+",z="+z+",n="+n);
}
}
免责声明:内容仅供参考,不保证正确性!