length一般用来求数组的元素个数。
length()方法用来求字符串的长度。
size一般用来求list中元素的个数;
例如:
class Array
{
public static void main(String [] args)
{
String array[]={"First","Second","Third"};
String a = "HelloWorld";
List<String>list=new ArrayList<String>();
list.add(a);
System.out.println("数组array的长度为"+array.length);
System.out.println("字符串a的长度为"+a.length());
System.out.println("list中元素个数为"+list.size());
}
}