日期:2014-05-20  浏览次数:20769 次

Java向List<ArrayList<String>> dataList = new ArrayList<ArrayList<String>>();中输出数据
List<ArrayList<String>> dataList = new ArrayList<ArrayList<String>>();
                     Object[] array = new Object[] {
      new String[] { "youth", "high","no","fair","no"  },
new String[] { "youth","high",     "no",      "excellent",     "no"  },
new String[] { "middle_aged",  "high",     "no",      "fair",          "yes" },
new String[] { "senior",       "medium",   "no",      "fair",          "yes" },
new String[] { "senior",       "low",      "yes",     "fair",          "yes" },
new String[] { "senior",       "low",      "yes",     "excellent",     "no"  },
new String[] { "middle_aged",  "low",      "yes",     "excellent",     "yes" },
new String[] { "youth",        "medium",   "no",      "fair",          "no"  },
new String[] { "youth",        "low",      "yes",     "fair",          "yes" },
new String[] { "senior",       "medium",   "yes",     "fair",          "yes" },
new String[] { "youth",        "medium",   "yes",     "excellent",     "yes" },
new String[] { "middle_aged",  "medium",   "no",      "excellent",     "yes" },
new String[] { "middle_aged",  "high",     "yes",     "fair",          "yes" },
new String[] { "senior",       "medium",   "no",      "excellent",     "no"  }
};
请各位大神,Java中如何往Object[]数组中的内容输入到List<ArrayList<String>> dataList = new ArrayList<ArrayList<String>>();
------解决方案--------------------
for(int i=0,len = array.length;i<len;i++){
ArrayList<String> b = new ArrayList<String>();
String[] h = (String[]) array[i];
int j = 0;
int jlen = h.length;
for(;j<jlen;j++){
b.add(h[j]);
}
dataList.add(b);
}

------解决方案--------------------
用add方法一个一个放进去吧;
------解决方案--------------------
不能用看错误信息。