版權(quán)聲明:本文為博主原創(chuàng)文章拔疚,轉(zhuǎn)載請說明出處侈询。
All operators
package AllOps;
public class AllOperators {
void f(boolean b){}
void boolTest(boolean x,boolean y){
f(x==y);
f(x!=y);
f(!y); //非運算
x=x&&y; //與運算
x=x||y; //或運算
x=x|y;
x=x^y;
x&=y; //按位與
x^=y; //按位異或
x|=y; //按位或
}
void charTest(char x,char y){
x=(char)(x%y);
x=(char)(x/y);
x=(char)(x*y);
x=(char)(x-y);
x=(char)(x+y);
x++;
x--;
x=(char)+y;
x=(char)-y;
f(x>y);
f(x>=y);
f(x<y);
f(x<=y);
f(x==y);
f(x!=y);
x=(char)~y;
x=(char)(x&y);
x=(char)(x|y);
x=(char)(x^y);
x=(char)(x<<1);
x=(char)(x>>1);
x=(char)(x>>>1);
x+=y; //鏈接不同的字符串 ,操作符重載
x-=y;
x*=y;
x/=y;
x%=y;
x<<=1;
x>>=1;
x>>>=1;
x&=y;
x^=y;
x|=y;
char c=(char)x;
byte b=(byte)x;
short s=(short)x;
long l=(long)x;
double d=(double)x;
}
void LongTest(long x,long y){
x=x*y;
x=x-y;
x=x+y;
x=x%y;
x=x/y;
x++; //后綴遞增,先生成值告抄,再執(zhí)行預算
x--;
x=+y;
x=-y;
f(x>=y); //大于等于
f(x>y);
f(x<y);
f(x<=y);
f(x==y);
f(x!=y);
x=~y; //按位非
x=x&y;
x=x^y;
x=x|y;
x=x<<1; //x左移位1痒玩,將得到結(jié)果返回x
x=x>>1;
x=x>>>1;
x+=y; //將x加y,并將結(jié)果返回給x
x-=y;
x*=y;
x/=y;
x%=y;
x<<=1;
x>>=1;
x>>>=1;
x&=y;
x|=y;
x^=y;
}
}
Attention
1.優(yōu)先級
2.賦值
3.算數(shù)運算符
4.自動遞增和遞減
5.關系操作符
6.邏輯操作符
7.java沒有sizeof