算术符变换常量

java 随堂笔记(3.16)

变换常量

转换型

public class 转换{
    public static void main(String[] args){
        double d = 10;// 10是int变量,占4个字符赋值双精度浮点型变量为8个字节
        // 10会自动变10.0
        System.out.println(d)
        byte b = 20;
        short s = b;
        int i = b;
        char c = 'a';
        int i2 = c;
        //  c = b
        //  强制类型转换
        int e = (int)88.88;
        System.out.println(e)
    }
}

算术运算符

public class 运算符{
    public static main void(String[] args){
        int a = 5;
        int b = 2;
        System.out.println(a+b)
        System.out.println(a-b)
        System.out.println(a*b)
        System.out.println(a/b)
        System.out.println(a%b)
        System.out.println("----------------")
        // 整数与整数运算结果只能是整数,结果要有小数就要
        // float参与
        // 除法的结果就是商,取余的结果只能是余数
        // ++ 就是变量的自增
        // 单独使用
        int c = 10;
        /**
        *c++;//10
        *++c://11
        *System.out.println(c);
        *参与运算
        *int d = c++;//++在变量的后面,先拿变量参与(赋		*在哪变量自增
        *d = 10,d = 11
        */
        int d = ++c;//++在变量前面,先拿变量自增,在拿			参与运算(赋值)
        // c = 11, d = 11
        System.out.println("c:"+c);//11
        System.out.println("d:"+d);//11
        System.out.println("----------------");
        // 赋值运算符:=  将“=”右边的赋值给左边
        int e = 10;//将10 赋值给了e
        //扩展赋值运算符: += -= *= /= %=
        //+=加等于  左边加上右边,结果赋值给了左边的变量
        e+=10;
        System.out.println("e:"+e);
        e *= 10
        System.out.println()
        System.out.println()
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值