ASC码和char

 1 package cn.sice;
 2 
 3 public class CharTest
 4 {
 5 
 6     public static void main(String[] args)
 7     {
 8         sop((char) 65633);// a
 9         sop((char) (65633 - 65536));// a
10     }
11 
12     public static void sop(Object obj)
13     {
14         System.out.println(obj);
15     }
16 
17     public static void method1()
18     {
19         // 把一个字符转换成它的ASC码
20         sop((int) '子');// 23376
21         sop((int) 'a');// 97
22         // 把一个字符的ASC码转换成该字符
23         sop((char) 97);// a
24         sop((char) 23376);//25         // 打印ASC
26     }
27 
28     public static void method2()
29     {
30         for (int i = 0; i <= 65535; i++)
31         {
32             if (i % 20 == 0 && i != 0)
33             {
34                 sop("");
35             }
36             System.out.print(i + ":");
37             System.out.print((char) i);
38 
39         }
40     }
41 
42 }

 

posted @ 2014-02-08 20:21  一路向北中  阅读(466)  评论(0)    收藏  举报