|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttips.shift.ShiftExample
ShiftExample is a sample class demonstrating the use of the Java >> >>> and << operators and demonstrating the difference between >> and >>>.
Usage: java ShiftExample Number ShiftBy
when using this program try both positive and negative numbers.
byte b = -64;
byte c = b >>> 4;
| Constructor Summary | |
ShiftExample()
Creates a new instance of ShiftExample |
|
| Method Summary | |
(package private) void |
display(int num,
int shift)
Go through a display the number in binary form, with an without the shift operators applied |
private java.lang.String |
format(int num)
Format a number in binary form. |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ShiftExample()
| Method Detail |
public static void main(java.lang.String[] args)
args - the command line arguments
void display(int num,
int shift)
private java.lang.String format(int num)
Note that your could use Integer.toBinaryString() but that will lose MSBs if ZERO.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||