访问列表<列表<字符串>>使用这个关键字
让我们假设我将值存储到列表A,列表B&中.通过for循环列出C. 列表A,B,C值通过以下方式添加:
Lets assume that I store values to List A, List B & List C through for loop. List A,B,C values is added by the following way:
for (int j = 0; j <5; j++)
{
list_A.add("Value"+i);
list_B.add("Value"+i);
list_C.add("Value"+i);
}
要通过以下方式使用我使用 this 关键字的方法访问列表:
To access the List out of the method I'm using this keyword by the following way:
private CharSequence ListA[]; // declaration
this.ListA= list_A.toArray(new CharSequence[list_A.size()]); //accessing with this keyword
现在,我通过以下方式将所有这些列表添加到另一个列表中
Now I am adding all these list to another List by the following way
List<List<String>> finallist = new ArrayList<>();
finallist .add(list_A);
finallist .add(list_B);
finallist .add(list_C);
我进行了一些搜索,但找不到如何声明和访问List<列表<字符串>>使用此关键字?
I did some searching but I couldn't find how to declare and access List< List< String>> using this keyword?
Note: It is the actual modification of the question that I have asked here. As I couldn't get any answer, I thought I could make it bit simple and have raised the question here.
访问另一类中的一个变量时,您可以执行以下操作:
When accessing a variable of one class in another, you could do something like this:
public static final List<String> list_A = new ArrayList<>();
static{
for (int j = 0; j <5; j++)
{
list_A.add("Value"+i);
}
}
片段类
CharSequence ListA[];
ListA = MainClass.list_A.toArray(new CharSequence[MainClass.list_A.size()]);
我建议在list_A