zoukankan      html  css  js  c++  java
  • 赋值运算符

    赋值运算符 :=

    扩展赋值运算符 :+=, -=, *=, /=, %=

    /*
    
        赋值运算符 :=
    
        扩展赋值运算符 :+=, -=, *=, /=, %=
    
    */
    public class SetValueTest{
    
        public static void main(String[] args){
        
        
            int a = 10;
            a += 5; //可以理解成 a = a + 5
            System.out.println(a);
    
            System.out.println("-----------面试题-------------------");
    
            byte b = 10;
            //b = b + 5; 编译不通过,因为byte参与运算会提升为int
            b += 5; //不会改变原来变量的类型。
            System.out.println(b);
    
            System.out.println("-----------课后题--------------------");
    
            int i = 1;
            i *= 0.1;
            System.out.println(i);//0
            i++;
            System.out.println(i);//1
    
        }
    }
  • 相关阅读:
    JS函数式编程【译】前言
    11.15周总结
    11.13
    11.12
    11.11
    11.10
    11.9
    11.8周总结
    11.6
    11.5
  • 原文地址:https://www.cnblogs.com/zmy-520131499/p/11047441.html
Copyright © 2011-2022 走看看