zoukankan      html  css  js  c++  java
  • Java日志第46天 2020.8.21

    2.1 将字符赋给整型变量

    public class Demo2_1 {
        public static void main(String[] args) {
            int i, j;
            i = 'A';
            j = 'B';
            System.out.println(i+ " " + j);
        }
    }

     

     

     

    2.2 字符数据与整数进行算术运算。下面程序的作用是将小写字母转换为大写字母。

    public class Demo2_2 {
        public static void main(String[] args) {
            char c1, c2;
            c1 = 'a';
            c2 = 'b';

            c1 = (char) (c1-32);
            c2 = (char) (c2-32);
            System.out.println(c1 + " " + c2);
        }
    }

     

    2.3 符号常量的使用

    public class Demo2_3 {
        public static void main(String[] args) {
            final int PRICE = 30;
            int num = 10;
            int total;
            total = num * PRICE;
            System.out.println("total = "+total);
        }
    }

    2.4 强制类型转换

    public class Demo2_4 {
        public static void main(String[] args) {
            float x;
            int i;
            x = 3.6f;
            i = (int) x;
            System.out.println("x = "+x+",i = "+i);

        }
    }

    2.5 将有符号数据传送给无符号变量

  • 相关阅读:
    玲珑oj 1129 ST
    HDU 3397 线段树区间修改
    bzoj 1798 双标记区间修改线段树
    HDU 4417 BIT or ST
    HDU 2492 BIT/逆序数/排列组合
    uva 12086 线段树or树状数组练习
    cf 833 A 数论
    wcf的DataContractAttribute与DataMenmberAttribute
    wcf服务查看工具
    git学习-综合性文章
  • 原文地址:https://www.cnblogs.com/Gazikel/p/13543167.html
Copyright © 2011-2022 走看看