java使用length属性获取数组长度
public static void main(String[] args) {
String fruits[]=new String[]{ "苹果","葡萄","桃子","哈密瓜","香蕉"," 橙","西瓜","火龙果","柿子","荔枝"}; //声明String型数组fruits
int len=fruits.length; //fruits的元素个数
for (int i=0;i<len ;i++ ){
System.out.print(fruits[i]+"\t");
}
System.out.println("\nfruits数组有"+len+"个元素!");//数组的元素个数
}