How to return array of a class in java
<p>I am trying to wrapp <code>TestClass1[]</code> in <code>TestClass</code> and for this I have created a <code>TestClass</code>. There is a method in another class <code>FunctionClass</code> which will return the array of the <code>TestClass</code>. I have defined some variables in <code>Testclass</code> one is <code>String</code> and the other one is a class <code>TestClass2</code>. I will wrapp the <code>TestClass2</code> in <code>Testclass</code>. <code>Testclass2</code> also has 2 variables, one is <code>String</code> and one is <code>int</code>. I want to know how can i construct an array of <code>Testclass</code> which should have the corresponding variables in it. I have the following code.</p>

<pre><code>public class Testclass {

private String attrName;
    private TestClass1 tc;
    private TestClass2 tc2;

Testclass(Testclass1[] tc1){

    for(int i=0; i&lt;tc1.length; i++){
    tc = tc1[i];
    attrName = this.tc.name; 
    tc2 = new TestClass2 (this.tc.elements); //this.tc.elements will return an Array of SomeClass which is not implemented by me.
    }

}

/**
 * Returns the Name.
 */
public String getName()
{
    return attrName;
}

/**
 * Returns the Testclass2 Array
 */
public TestClass2[] getTestClass2(){

//What to do ??
}



 /**
 * Testclass2 which is inner class of TesTClass.
 */
 private class Testclass2 {

    private int value;
    private string attribute;
    private SomeClass some;

    TestClass2 (SomeClass[] someClass){

        for(int i=0; i&lt;someClass.length; i++){
        some= someClass[i]; 
        this.value= some.value;
                    this.attributes = some.attribute;

        }
    }

            /**
             * Returns the Value.
             */
    public int getValue(){
        return value;
    }

            /**
             * Returns the Attribute.
             */
            public string getAttribute(){
        return attribute;
    }
</code></pre>

<p>Method in Function class is as follows</p>

<pre><code>public Testclass[] getTestClass(){

 //What to do?

}
</code></pre>

<p>Thanks in advance.</p>
