我想向此2D ArrayList添加另一行,因此我可以添加另一列表。我该怎么办?
类似...
List<List<String>> text_list = new ArrayList<List<String>>();
text_list.get(0).add("another list item");
text_list.addRow();
text_list.get(1).add("another row list item");
答案 0 :(得分:0)
ArrayList是一个动态集合。只需不断添加元素,它的容量就会在需要时自动增长。
演示:
detailVC.center = view.center
detailVC.bounds.size.width = view.bounds.width
detailVC.bounds.size.height = view.bounds.height
view.addSubview(detailVC)
输出:
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<List<String>> text_list = new ArrayList<List<String>>();
text_list.add(List.of("One", "Two", "Three"));
text_list.add(List.of("Four", "Five", "Six", "Seven"));
for (List<String> list : text_list) {
System.out.println(list);
}
}
}