wood burning stoves 2.0*
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Shift operator
 
Similar Threads
Shift operator....
Shift operator doubt
shift question
Please clarify this bitwise shifting
shift