【发布时间】:2013-07-02 01:21:50
【问题描述】:
我有一个 ArrayList,例如:ArrayList<ArrayList<String>> test
for(int i = 0; i < test.size(); i++) {
ArrayList temp = test.get(i);
}
现在事实证明,我不能这样做Arrays.deepToString(temp.toArray()),因为 temp 是一个对象,而不是
另外,我正在做temp1.contains(temp.get()) temp1 和 temp2 实际上是具有相同值的对象
有什么方法可以让我基本上返回一个 ArrayList 左右而不是一个对象,这样我就可以让 .contains() 方法工作。正如我所说... temp 中的 ArrayList 具有相同数量的列,其中一些具有相同的值。
请帮帮我。
【问题讨论】:
-
为什么不将 temp 声明为
ArrayList<String>? -
注意:你也可以使用 foreach 使其更清晰:
for(ArrayList<String> temp : test){ ... }
标签: java object arraylist getter-setter object-to-string