jeudi 5 mars 2020

How to new a nested structure dynamically?

from How to get all types of the inner structures of a nested type?, I know how to get the inner structures of a nested data type. But, how to new this type dynamically?

That is, I can create a nested data type with static code, say,

LinkedList<LinkedList<LinkedList<Object>>> obj=new LinkedList<>();

But, if the layers of the inner of the structure is variable, how to do that with a program? Any ideas are appreciated.

Edit: For example,

public void foo(LinkedList<LinkedList<LinkedList<Object>>> inputParameter);  
//this line has to be changed because the number of inner LinkedList is variable.
LinkedList<LinkedList<LinkedList<Object>>> list=new LinkedList<>();
//call    
foo(list);




Aucun commentaire:

Enregistrer un commentaire