File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes >>> 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 ">>> operator" Watch ">>> operator" New topic

>>> operator

Eugene Lea

Joined: Sep 30, 2002
Posts: 12
int i = Integer.MIN_VALUE;
byte b = Byte.MIN_VALUE;
Why for i output positive value, for b output negative value ?
Alfred Kemety
Ranch Hand

Joined: Aug 14, 2002
Posts: 279
Integer.MIN_VALUE = 80000000
Byte.MIN_VALUE = 80 = 10000000
when applying the >>> to the byte, it first gets promoted to int then get shifted.
after being shifted because of >>>= it gets implecitly casted back to byte so the value gets truncated.
the output of this code should make you understand what happens.

[ October 14, 2002: Message edited by: Alfred Kemety ]

Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
I agree. Here's the link:
subject: >>> operator
It's not a secret anymore!