aspose file tools*
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Bitwise operator" Watch "Bitwise operator" New topic
Author

Bitwise operator

wei Qiao
Greenhorn

Joined: Jun 19, 2000
Posts: 23
Hi,
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).
Thanks!
Wei
PS. I am planning to take the test this Friday.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12836
    
    5
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.
Anonymous
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