testprimitive.java
来自「北京尚学堂J2SE所有的源代码!!北京尚学堂J2SE所有的源代码!!」· Java 代码 · 共 22 行
JAVA
22 行
public class TestPrimitive {
public static void main(String[] args) {
Integer i = new Integer(100);
Double d = new Double("123.456");
int j = i.intValue()+d.intValue();
float f = i.floatValue()+d.floatValue();
System.out.println(j); System.out.println(f);
double pi = Double.parseDouble("3.1415926");
double r = Double.valueOf("2.0").doubleValue();
double s = pi*r*r;
System.out.println(s);
try {
int k = Integer.parseInt("1.25");
} catch (NumberFormatException e) {
System.out.println("数据格式不对!");
}
System.out.println(Integer.toBinaryString(123)+"B");
System.out.println(Integer.toHexString(123)+"H");
System.out.println(Integer.toOctalString(123)+"O");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?