1,java中主要提供两种生成随机数的方法,分别为Math类的random()方法和调用Random类生成各种数据类型的随机数。
2,Scanner类,用来从控制台读取用户输入,例如:
int i;
Scanner sc = new Scanner(System.in);
i = sc.nextInt();
System.out.println(i);
3,String的常用方法
trim(),是忽略前导空格和尾部空格
equalsIgnoreCase(),另一个常用方法,作用是忽略大小写比较字符串是否相等
语法如:str.equalsIgnoreCase(String otherStr);
4,
String s1 = null;
String s2 = "hello" + s1;
System.out.println(s2);
问,打印结果是什么?
答案是hellonull