【发布时间】:2016-08-17 23:14:57
【问题描述】:
我有以下二维数组:
[[Reflux Symptom Sensitivity Index (Impedance)], [Symptom Acid Nonacid All Reflux], [Regurgitate 34% 71% 36%], [Stomach pain 21% 14% 19%], [Chest pain 3% 0% 3%], [], [Reflux Symptom Association Probability (Impedance)]]
我想将除第一个数组之外的所有内部数组都使用空格,以便最终得到:
[[Reflux Symptom Sensitivity Index (Impedance)], [Symptom,Acid, Nonacid, All, Reflux], [Symptom,Acid, Nonacid, All, Reflux], [Symptom,Acid, Nonacid, All, Reflux],[Chest pain,3%,0%,3%]]
我可以写如下代码:
ArrayList<List<String>> Arr_RSI_table2d = new ArrayList<List<String>>();
List<String> stats = Arr_RSI_table2d.get(1);
// remove() returns the object that was removed
String allStats = stats.remove(0);
String allStats2=allStats.trim();
Collections.addAll(stats, allStats2.split("\\s"));
List<String> Arr_RSI_table2d_col2 = Arr_RSI_table2d.get(2);
// remove() returns the object that was removed
String All_Arr_RSI_table2d_col2 = Arr_RSI_table2d_col2.remove(0);
String All_Arr_RSI_table2d_col2_2=allStats.trim();
Collections.addAll(Arr_RSI_table2d_col2, All_Arr_RSI_table2d_col2_2.split("\\s"));
List<String> Arr_RSI_table2d_col3 = Arr_RSI_table2d.get(3);
// remove() returns the object that was removed
String All_Arr_RSI_table2d_col3 = Arr_RSI_table2d_col3.remove(0);
String All_Arr_RSI_table2d_col3_2=allStats.trim();
Collections.addAll(Arr_RSI_table2d_col3, All_Arr_RSI_table2d_col3_2.split("\\s"));
List<String> Arr_RSI_table2d_col4 = Arr_RSI_table2d.get(4);
// remove() returns the object that was removed
String All_Arr_RSI_table2d_col4 = Arr_RSI_table2d_col4.remove(0);
String All_Arr_RSI_table2d_col4_2=allStats.trim();
Collections.addAll(Arr_RSI_table2d_col4, All_Arr_RSI_table2d_col4_2.split("\\s"));
我该怎么做?
【问题讨论】:
-
投反对票的原因是?...
标签: java arraylist multidimensional-array