package cn.edu.bjut.chapter2; public class IntegerTester { public static void main(String[] args) { System.out.println(Short.MIN_VALUE); System.out.println(Short.MAX_VALUE); System.out.println(Byte.MIN_VALUE); System.out.println(Byte.MAX_VALUE); byte a = 5; String a2 = String.format("%8s", Integer.toBinaryString(a & 0xFF)).replace(' ', '0'); System.out.println(a2); System.out.format("0x%x\n", a); System.out.format("0%o\n", a); byte b = -5; String b2 = String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'); System.out.println(b2); System.out.format("0x%x\n", b); System.out.format("0%o\n", b); } }