This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Shift 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 "Doubt in Shift operator" Watch "Doubt in Shift operator" New topic
Author

Doubt in Shift operator

R .sourav nayak
Ranch Hand

Joined: May 14, 2006
Posts: 67
Could some explain me how the out put is i =-1 and j=0 from the following code:


public class Q5
{
public static void main(String[] args)
{
int i = 1;
i <<= 31;
i >>= 31;
i >>= 1;

int j = 1;
j >>= 31;
j >>= 31;

System.out.println("i = " +i );
System.out.println("j = " +j);

}
}
thanks in advance.
reena
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
How do the '>>', '>>>', and '<<' operators work?
 
Have you checked out Aspose?
 
subject: Doubt in Shift operator
 
It's not a secret anymore!