欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数据类型转换

程序员文章站 2024-03-26 11:41:47
...
   char c= '8';
        //char cc= '0';
        int i = c-'^';
        int j=  c+'0';
        char ch = '9';
        int in = '\0';
        System.out.println(i);
        //*System.out.println(i);

        //1.
    int a=5;
        String s = String.valueOf(a);
        System.out.println(s);

        //3.
        double d=15.2551;
        BigDecimal b = new BigDecimal(d);
        BigDecimal big = b.setScale(2, RoundingMode.HALF_UP);
        System.out.println(big);

        String s1 = big.toString();
        String s2 = s1.substring(s1.length() - 2);
        System.out.println(s2);