首页 > 其他 > 详细

chapter3

时间:2015-03-26 23:04:20      阅读:318      评论:0      收藏:0      [点我收藏+]
 1 public class Chapter3 {
 2     
 3     static int times=3;//成员变量
 4     
 5     public static void main(String[] args){
 6         
 7         byte mybyte=124;
 8         short myshort=32564;
 9         int myint=45784612;
10         long mylong=2343523444L;
11         long result=mybyte+myshort+myint+mylong;
12         System.out.println("结果为:"+result);    
13         
14         
15         float f=3.14f;//不加f会报错
16         System.out.println(f);
17         char word=‘d‘,word2=‘@‘;
18         int p=23045,p2=41;
19         System.out.println("d在Unicode表中的顺序位置是:"+(int)word);
20         System.out.println("@在Unicode表中的顺序位置是:"+(int)word2);
21         System.out.println("Unicode表中23045位是:"+(char)p);
22         System.out.println("Unicode表中45213位是::"+(char)p2);
23         
24         char c1=‘\\‘;
25         char c2=‘\u2605‘;
26         System.out.println(c1);
27         System.out.println(c2);
28         
29         boolean b=false;
30         System.out.println(b);
31         
32         final double PI;//局部终态变量
33         PI=3.141592654;
34         //常量在整个程序中只能被赋值一次
35         //PI=3.14;  
36         System.out.println(PI);
37         
38         System.out.println(times);
39         int times=4;
40         System.out.println(times);
41         
42         int i=1;
43         System.out.println(i+(i++)+(++i));
44         
45         
46         //byte<short<int<float<double,高精度转低精度要强制类型转换(显式类型转换);超范围也要要强制转换
47         int a1=(int)45.23;
48         long a2=(long)456.5F;
49         int a3=(int)‘d‘;
50         byte a4=(byte)132;
51         System.out.println(a1);
52         System.out.println(a2);
53         System.out.println(a3);
54         System.out.println(a4);//显示-124
55     }
56 }

 

chapter3

原文:http://www.cnblogs.com/thunsir/p/4369929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!