赋值运算符

1.package 赋值运算符;
public class Example01 {
     public static void main(String[] args) {
              short s=3;
              int i=5;
              s+=i;
             System.out.println("s="+s);
     }
}

结果:

 

 

2.package 赋值运算符;

public class Example02 {

      public static void main(String[] args) {
          int x=0; //定义变量x,初始值为0
          int y=0; //定义变量y,初始值0
          int z=0; //定义变量z,初始值0
         boolean a,b; //定义boolean变量a,b
         a=x>0&y++>1; //逻辑运算符&对表达式进行运算
         System.out.println(a);
         System.out.println("y="+y);
          b= x>0 && z++>1; //逻辑运算符&&对表达式进行运算
         System.out.println(b);
         System.out.println("z="+z);
    }

}

结果:

 

posted on 2020-10-13 09:15  张德明  阅读(77)  评论(0)    收藏  举报