黑马程序员_java基础

---------------------- <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 4
case 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值