/Users/lyon/j4p/src/bookExamples/ch04BaseConvesion/IntegerTest.java

1    package bookExamples.ch04BaseConvesion; 
2     
3    public class IntegerTest { 
4        public static void main(String args[]) { 
5            println("hello world"); 
6            printHex(65535); 
7            for (int i = 24; i < 52; i++) { 
8                print((char) i + ""); 
9            } 
10       } 
11    
12       public static void printHex(int i) { 
13           println(Integer.toString(i, 16)); 
14       } 
15    
16       public static void print(int i) { 
17           System.out.print(i); 
18       } 
19    
20       public static void println(int i) { 
21           System.out.println(i); 
22       } 
23    
24       public static void print(Object o) { 
25           System.out.print(o); 
26       } 
27    
28       public static void println(Object o) { 
29           System.out.println(o); 
30       } 
31    
32       public static void numberTest( 
33               int i, 
34               double d) { 
35           float f = 1.2f; 
36           short s = 3; 
37           byte b = -4; 
38           char c = 'J'; 
39           boolean t = true; 
40           long l = 3294; 
41           System.out.println( 
42                   "i=" + i + 
43                   "\nd=" + d + 
44                   "\nf=" + f + 
45                   "\ns=" + s + 
46                   "\nb=" + b + 
47                   "\nc=" + c + 
48                   "\nt=" + t + 
49                   "\nl=" + l + 
50                   "\ni=" + 
51                   Integer.toString(i, 36) + 
52                   "+" + 
53                   Integer.toString(s, 36) + 
54                   "=" + 
55                   Integer.toString(s + i, 36)); 
56    
57           f = (float) d; 
58           b = (byte) f; 
59           c = (char) f; 
60    
61       } 
62   } 
63