1. 数据类型
八种基本数据类型:byte,short,int,long,float,double,boolean,char
1)int:整型,4个字节,5,25,250…
2)long:长整型,8个字节,5L,1000000000000L…
3)double:浮点型,8个字节,3.14,25.78,56.0…
4)boolean:布尔型,1个字节,true,false
5)char:字符型,2个字节,‘你’,‘y’,‘7’,’*’,’’’…
2. 类型转换
类型间的转换:
1)自动类型转换:小到大
强制类型转换:大到小 (要转换成为的数据类型)变量 有可能溢出或丢失精度
2)short s1 = 5;
short s2 = 6;
short s3 = (short)(s1+s2);
3. Math.random
1到1000之内
Math.random()---------------0.0到0.9999999999999…
*1000-----------------------0.0到999.99999999999…
+1--------------------------1.0到1000.9999999999…
(int)-----------------------1到1000