前言:数组没有length()这个方法,有length的属性。String有有length()这个方法。
1.String字符串
String str = "abcdefg";
str.length();
2.Array数组
int[] arr = new int[10];
System.out.println(arr.length);
3.List集合
List list = new ArrayList();
list.size();
4.JSONArray
String jsonMessage =
"[{'num':'成绩','外语':88,'历史':65,'地理':99,'object':{'aaa':1111,'bbb':2222,'ccc':'3333'}},"
+ "{'num':'兴趣','外语':28,'历史':45,'地理':19,'object':{'aaa':1a11,'bbb':2a22,'ccc':'3a33'}},"
+ "{'num':'兴趣','外语':48,'历史':62,'地理':39,'object':{'aaa':1aaa,'bbb':2bb2,'ccc':'3c33'}}]";
JSONArray myJsonArray = JSONArray.fromObject(jsonMessage);
for (int i = 0; i < myJsonArray.size(); i++)
{
//遍历
}