search 登录 注册
arrow_back返回列表
ID:54295
light_modedark_modedark_modestar
Lv.3 畅意三江水
edit_note帖子 386
stars积分 53,287
event加入 2011-06-21
美化修改

JAVA 的基本语法之空白语法

schedule发表于 2013-06-22 22:55:00 visibility查看 524 chat_bubble回复 15
#1 楼主
在Java程序中,换行符及回车键都可
表示一行的结束,它们可被看作是空
白。另外,空格键、水平定位键(tab)
亦是空白。为了增加可读性,Java程
序的元素之间可插入任意数量的空
白,编译器将忽略掉多余的空白。
程序中除了加入适当的空白外,还应
使用缩进格式,使得同一层语句的起
始列位置相同。如下面两段代码中,
虽然它们的所有语句都一样,但第二
种写法的程序设计风格更好,更清晰
易读。
两种程序风格的比较
(1)不提倡的程序风格
∥一种不好的风格
class.Point{int x,y;Point(int
x1,int y1){x=x1;
y=y1;
}
Point(
){this(O,O);)
void
moveto(int x1,int y1){
x=x1;y=y1;
}}
(2)提倡的程序风格
∥好的风格
class Point{
int x,y; //点的x,y坐标
Point(int x1,int y1){ ∥构造方法
x=x1;
y=y1;
}
Point(){ //构造方法
this(O,0);
}
void moveto(int x1,int y1){ //
点移动到(xl,y1)
x=x1 ;
y=y1;
}
}

全部回复 (15)

ID:6048
light_modedark_modestarstarstar
Lv.5 甘首五朝臣
2013-06-22 22:56:00 沙发
好帖,要顶!
ID:110038
light_modedark_modestar
Lv.2 独赏二月雪
2013-06-22 23:29:00 板凳
看帖回帖是美德!
ID:136524
light_modedark_modestarstar
Lv.6 胸怀六国志
创世成员
2013-06-23 10:19:00 地板
支持你!
ID:135730
dark_modedark_modedark_modestarstarstar
Lv.2 独赏二月雪
2013-06-29 19:28:00 #5
看 看
ID:110250
light_modedark_mode
Lv.5 甘首五朝臣
2013-07-09 22:58:00 #6
看帖回帖是美德!
ID:64412
light_modestarstarstar
Lv.2 独赏二月雪
2013-07-20 22:15:00 #7
支持你!
ID:133210
light_modedark_mode
Lv.3 畅意三江水
2013-07-21 03:50:00 #8
看帖回帖是美德!
ID:140129
dark_modedark_modestarstar
Lv.1 韶华一笑间
2013-07-24 18:57:00 #9
表情好帖,要顶!
ID:101316
light_modestarstarstar
Lv.1 韶华一笑间
2013-11-19 11:47:00 #10
哦哦
ID:123392
light_modestarstarstar
Lv.1 韶华一笑间
2013-11-25 18:48:00 #11
地方擦擦擦
ID:91131
dark_modestarstarstar
Lv.1 韶华一笑间
2013-11-25 19:09:00 #12
喔喔哦默默
ID:122852
dark_modedark_modedark_modestarstarstar
Lv.1 韶华一笑间
2013-11-30 06:20:00 #13
ktdh
ID:143729
light_modedark_mode
Lv.1 韶华一笑间
2013-12-02 10:12:00 #14
ID:140862
light_modedark_mode
Lv.1 韶华一笑间
2014-08-08 16:48:00 #15
哦哦哦哦哦哦哦哦哦了*
ID:140484
light_modestar
Lv.1 韶华一笑间
2014-08-20 00:01:00 #16
链接
登录 后才能回复