jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Bitwise operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Bitwise operator" Watch "Bitwise operator" New topic

Bitwise operator

wei Qiao

Joined: Jun 19, 2000
Posts: 23
What type does bitwise operator &, ^, | take? I know thet take integer(that's what is said on Robert's book). Also It takes boolean( even "true" and "false" keywords).
PS. I am planning to take the test this Friday.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13025
When used with integer primitive values, | & and ^ are bitwise operations, when used with boolean they are of course boolean.
In integer expressions, both sides are promoted to int or to long if one is long before the bitwise operation is carried out.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The bitwise operators can operate on all INTEGRAL types and not only int. as u said.In addition they can also be used with boolean literals(true and false).In that case true is treated as 1 and false as 0.The result is of type boolean.
I agree. Here's the link: http://aspose.com/file-tools
subject: Bitwise operator
It's not a secret anymore!