Reference:
-
two types of array declaration:
dataType[] arrayRefVar;anddataType arrayRefVar;. The former is preferred, while the latter is for the convenience of C++ programmers. -
lengthlength()size().length属性针对数组,length()针对字符串string,size()针对泛型集合。 -
List lt;会报错List lt = new ArrayList();则不会报错。自定义对象如果不初始化,再访问时报错java.lang.NullPointerException。 -
用
==比较字符串实质是比较地址,永远不相等,应该使用equals()方法。