`
ansjsun
  • 浏览: 199743 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java中比较罕见的运算符

 
阅读更多
java中比较罕见的运算符发现一个举报一个.随时更新欢迎补充.

第一个
//位移.
16>>>2 = 4 


//“&”代表与运算符两个条件都成立才算成立;“
int i = 1 ;
		int j = 3 ;
		System.out.println(i&j);

打印结果会是1
因为1 是01
   3 是 11

01&11 = 1


//“|”代表或者运算符两个条件有一个成立就算成立;“
int i = 1 ;
		int j = 3 ;
		System.out.println(i&j);

打印结果会是1
因为1 是01
   3 是 11

01&11 = 3


//“ˆ”代表异或运算符,对应的二进制位相同为零,不相同为1
int i = 1 ;
		int j = 3 ;
		System.out.println(i&j);

打印结果会是1
因为1 是01
   3 是 11

01&11 = 2


分享到:
评论
4 楼 ansjsun 2011-09-13  
ansjsun 写道
chujiazhen 写道
what is the difference of '>>>' and '>>',thanks


一个是有符号右移.一个是无符号的...

System.out.println(-10>>2);
System.out.println(-10>>>2);

test this you will know
3 楼 ansjsun 2011-09-13  
chujiazhen 写道
what is the difference of '>>>' and '>>',thanks


一个是有符号右移.一个是无符号的...
2 楼 chujiazhen 2011-09-13  
what is the difference of '>>>' and '>>',thanks
1 楼 vigorous2008 2011-09-11  
或运算、异或运算的System.out.println() 都写成与运算了

相关推荐

Global site tag (gtag.js) - Google Analytics