1.随机函数的应用
int x=(int)(Math.random()*10);//范围[0,10] 方法1
Random y=new Random()
x = y.nextInt(10);;//范围[0,10] 方法2
x=5+y.nextInt(20-5+1);//范围[5,20]
2.包装类
Character c1 = new Character('a');
System.out.println(c1);
if(Character.isLowerCase(c1))//如果c1是小写字母
c1 = Character.toUpperCase(c1);//转大写
double d = Double.parseDouble("3.14");//字符串转数字
3.集合
List<student> stu=new ArrayList<student>();
stu.add(new student());//添加新的元素
stu.add(new student("小明",1001,true,18));
for(student stus:stu)
{//迭代循环
System.out.println(stus.toString());
}
Map<String,student> map=new HashMap<String,student>();
map.put("1", new student());//放
student stus=map.get("1");//取
for(String key:map.keySet()) {//对 键集合 遍历,实现对map遍历
stus=map.get(key);//根据键值对取值