java例程练习(基础数据类型的包装类)

来源:互联网 发布:周扬青淘宝店链接 编辑:程序博客网 时间:2024/06/06 01:06
public class Test {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.23");System.out.println(k);} 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");}}