我有3个布尔变量,表示是否将一个整数添加到列表中,然后我想在这个列表上使用
TextUtils.join()
方法。应该如何操作?ArrayList<Integer> types = new ArrayList<Integer>();
if (m_bWithA) {
types.add(this.TYPE_A); //TYPE_A is an int
}
if (m_bWithB) {
types.add(this.TYPE_B);
}
if (m_bWithC) {
types.add(this.TYPE_C);
}
TextUtils.join("|", types);
但是它说我们只能在 Object[]
上使用 TextUtils.join()
。
我应该使用另一个函数还是不同类型的对象?
ArrayList
不是一个可迭代对象吗?它可以被.join
这里 接受。 - Sourabh