摘要:逻辑或和逻辑或的区别和共同点。以下是我们为大家整理的,相信大家阅读完后肯定有了自己的选择吧。
public class Logic { public static void main(String []args) { int a=3; int b=2; if(a>2 || b++>2)//左边为true,所以不再判断右边的结果,直接执行if { System.out.println("a的值是:"+a+" b的值是:"+b);//a=3 b=2 } a=3; b=2; if(a>2 | b++>2)//左边为true,再判断右边为false,执行if { System.out.println("a的值是:"+a+" b的值是:"+b);//a=3 b=3 } } }