昨天休息了一天,今天弄了一天蓝牙耳机,连不上笔记本....快两天没学习了。
于是今晚把之前学的准备复习巩固一遍,加油奥利给。
写写值得注意的点:
一、Java中的byte,short,char进行计算时都会提升为int类型。
二、java中的switch选择结构可以使用数据类型的数据:
1, int
2,char
3,byte
4,short
5,枚举
6, String:
String 类型对JDK版本有要求,必须为1.7及以上版本
三、for循环里面的局部变量在循环结束后就失效,所以定义要在for循环外面。
四、ArrayList类的常用方法还有set方法来更新集合元素:E set(int index, E element)
五、String类常用的方法有:equals、indexOf、replace、concat、substring....
beginIndex - 起始索引(包括)。
endIndex - 结束索引(不包括)。
六、继承中,没有同名变量、同名方法的情况很简单,子类没有往上找即可。
若有重名的变量,优先使用子类的重名变量,若想调用父类的重名变量,使用super关键字即可,子类想使用继承下来的private同名变量,需要调用父类的get方法
七、接口中的普通方法必须写上default 。
八、“引用类型变量+字符串”的地址和“字符串+字符串”的地址不一样。
String s1 = "ab";
String s2 = "abc";
String s3 = s1 + "c";
System.out.println(s3 == s2); //false
System.out.println(s3.equals(s2)); //true
String s1 = "a" + "b" + "c";
String s2 = "abc";
System.out.println(s1 == s2); //true
System.out.println(s1.equals(s2)); //true