*
* 字符串 算术运算符运用(%模运算 /取余
*/
public class CharDemo {
/*
* 比较运算符结果不是true就是false
* &:与 |:或
* &:运算特点: true&ture = true
* true& false = false
* false& ture = false
* flase& false = false
* |或 运算特点 true | true = true
* true | false = true
* false |ture = true
* false | false = false
* 短路||的运算结果跟"|"一样 但是有点小区别
* 无论左边结果是什么.右边都参与预算 .
*/当左边是true 时右边不参与运算.
static void test(int x){//构造方法
System.out.println(x > 2 & x < 5);
System.out.println(x>2);
System.out.println(x==2);
System.out.println(x > 3 | x < 2);
}
public static void main(String [] args){
int a = 5;
int b ;
a++;
b = a++;
int i = 3;
i = i++;
short y =3;
y += 4;
test(3);
System.out.println("a="+a+",b"+b);
System.out.println(7%2);//模运算奇数模2都于余1 偶数模2都余0
System.out.println("i="+i);
System.out.println("y="+y);
/* ^:异或:
* true ^ true = true
* false ^ false = false
* 特点两边结果相同 是flase
* 两边结果不同是ture
* &; 无论左边运算结果是什么, 右边都参与运算
*短路&&:当左边是 false 右边都参与运算
*/运算结果与&一样 有点小区别
}
}