It's not a secret anymore!
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

bitwise operator

prafulla shrikhande

Joined: Mar 12, 2003
Posts: 4
this was a good one on bitwise operators -

i = 1;

i <<= 31;
i >>= 31;
i >>= 1;

whats the value of i?
Pedro Ivo Dantas

Joined: Sep 03, 2004
Posts: 10
It depends on the type of the variable i. If it is a int, as I suppose was your intention, then the resulting value will be -1 (11111...1111). If it is a long, then the result will be 0.
I agree. Here's the link:
subject: bitwise operator
jQuery in Action, 3rd edition