This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

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.
It is sorta covered in the JavaRanch Style Guide.
subject: bitwise operator
It's not a secret anymore!