黑马程序员_java基础

来源:互联网 发布:淘宝司法拍卖是什么 编辑:程序博客网 时间:2024/04/28 03:19
---------------------- <a target=_blank href="http://www.itheima.com" target="blank" style="font-family: Simsun;font-size:14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">android培训</a><span style="font-family:Simsun;font-size:14px;color:#000000;font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">、</span><a target=_blank href="http://www.itheima.com" target="blank" style="font-family: Simsun;font-size:14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">java培训</a><span style="font-family:Simsun;font-size:14px;color:#000000;font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">、</span>期待与您交流! ----------------------

1 标示符规则

(1)  由0——9,a----z, A-----Z,_,$等符号组成

(2) 不能以数字开头。

(3) 不能使用关键字,比如public,static等


2 命名规范

(1)  包名 ————全部小写,如 xxxyyyzzz。

(2) 类及接口名————各单词首字母大写,如XxxYyyZzz。

(3)变量及函数名————第一个单词首字母小写,其他单词首字母大写,其余均小写,如xxxYyyZzz。

(4)常量名————所有字母均大写,各单词间下滑线连接,如XXX_YYY_ZZZ。


3类型转换规则

范围小的可以向范围大的转换(碗里的东西倒进盆里),反之报错。

bite b=3,b=b+2。报错。需要对后面一句进行强制类型转换。b=(byte)(b+2)。

类型转换过程中可能丢失精度,出现这种情况时,低位数据保留,高位数据丢失。



4其他细节

-1%5=-1而不是4

字符串和其它任意类型数据“+"都是连接运算,结果是字符串。

&&与&的区别————&&左边为假,右边不运算。而&两边都运算。这2种符号连接的2边有变量增减时要特别注意。

||与|的区别同上,|两边都运算,||左边为真,右边不运算。

>>————右移时补最高位。

>>>————右移时补0。



5不用中间变量交换

n=n+m,

m=n-m,

n=n-m.

或者

n=n^m,

m=n^m,

n=n^m.


6case语句


switch(month){     //switch语句一直执行,直到碰到break;或者执行到结尾才结束,而且多个case可以共用同一段处理语句case 3:case 4case 5:System.out.println("春季");break;case 6:case 7:case 8:System.out.println("夏季");break;case 9:case 10:case 11:System.out.println("秋季");break;case 12:case 1:case 2:System.out.println("冬季");break;default:System.out.println("您输入的月份有误");break;}}


0 0
原创粉丝点击