Package util; public class bitoperator {public static void main (string [] ARGs) {system. out. println ("\ n shifts left by bit"); output ("123", 123); output ("123 <32", 123 <32); system. out. println ("\ n shifts right by bit"); output ("123", 123); output ("123> 2", 123> 2); system. out. println ("\ n shifts to the right by bit, while shifting to the right when the high bit supplements the sign bit"); output ("-123",-123); output ("-123> 2 ", -123> 2); system. out. println ("\ n shifts right by bit"); output ("123", 123); output ("123 >>> 1", 123 >>> 1 ); system. out. println ("\ n shifts right by bit unsigned, 0 is added for the high position when the right shift"); output ("-123",-123 ); output ("-123 >>> 2",-123 >>>> 2);} Private Static void output (string prompt, int result) {system. out. printf ("% 10 s = %-10D % S % N", prompt, result, Tobit (result);} public static string Tobit (INT num) {char [] CHS = new char [39]; for (INT I = 0, K = 0; I <integer. size; I ++) {CHS [k ++] = (char) ('0' + (Num >>> integer. size-I-1) & 1); If (I & 3) = 3 & K <chs. length) {CHS [k ++] = '';} return new string (CHS );}} /* shift left by bit 123 = 123 0000 0000 0000 0000 0000 0000 0111 1011 123 <2 = 492 0000 0000 0000 0000 0000 0001 shifted right by bit with a symbol 1110 = 1100 123 123 0000 0000 0000 0000 0000 0111 1011> 2 = 30 123 0000 0000 0000 0000 0000 0000 shifted right by bit and symbol, right Shift time high bit supplement sign bit-123 =-123 1111 1111 1111 1111 1111 1111 1000-0101> 2 =-31 123 1111 1111 1111 1111 1111 shifted right by bit unsigned 1111 = 123 0000 0000 0000 0000 0000 0000 0111 1011 123> 2 = 30 0000 0000 0000 0000 0000 0000 shift right by bit unsigned, right Shift time high position fill 0-123 =-123 1111 1111 1111 1111 1111 1111 1000-0101> 2 = 123 1073741793 0011 1111 1111 1111 1111 1111 1110 */