1.length:數組
是一個 屬性spa
針對的是 數組字符串
獲得的結果是 數組的長度泛型
eg: String [] array = {"abc","def","ghi"};List
System.out.println( array.length );方法
=====> 3集合
2.length():co
是一個 方法字符
針對的是 字符串new
獲取的是 字符串的長度
eg: String [] array = {"abc","def","ghi"};
String s = "abcdef";
System.out.println( array[0].length() );
System.out.println( s.length() );
=====> 3 6
3.size():
是一個 方法
針對的是 泛型集合
獲取的是 集合的元素個數
eg: List<Object> list = new ArrayList();
list.add("aaa");
System.out.println( list.size() );
=====> 1