当前位置:编程学习 > JAVA >>

java小程序TestBooleanOperator

package ch3;
public class TestBooleanOperator {
 public static void main(String[] args) {
  boolean b1, b2;
  b2 = false;
  b1 = ! b2; www.zzzyk.com
  System.out.println("逻辑值:b1 + " + b1 + ",b2 = "  + b2);
  System.out.println("逻辑与:b1 & b2 = " + (b1 & b2));
  System.out.println("逻辑或:b1 | b2 = " + (b1 | b2));
  System.out.println("逻辑疑惑:b1 ^ b2 = " + (b1 ^ b2));
 
  int x = 3, y = 9;
  b1 = x > y && x ++ == y --;
  System.out.println("短路与的结果 :" + b1 + "x = " + x + "y = " + y);
 
  x = 3;
  y = 9;
  b2 = x > y & x ++ == y --;
  System.out.println("逻辑与的结果:" + b2 + "x = " + x + " y = " + y);
 }
}
补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,