think in java 笔记(5.2)
Random r = new Random(47); System.out.println(r.nextInt(3));
创建Random对象时,传入一个种子数字,如47,每次生成的随机数都是相同的。
2.在char、byte、short的算术运算中,计算结果会自动转换成int,如果再将结果赋值给char、byte、short,需要强制转型
char c1 = 3; char c2 = 3; char c = (char)(c1 / c2);
但复合赋值不需要类型转换
c += c2;
3.字符串不能使用比较运算符进行比较(能用==或!=)
String s1 = "s"; String s2 = "s"; //System.out.println(s1 < s2);