Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:19:07+00:00 2026-06-14T13:19:07+00:00

I am trying to wrap TestClass1[] in TestClass and for this I have created

  • 0

I am trying to wrap TestClass1[] in TestClass and for this I have created a TestClass. There is a method in another class FunctionClass which will return the array of the TestClass. I have defined some variables in Testclass one is String and the other one is a class TestClass2. I will wrap the TestClass2 in Testclass.

Testclass2 also has 2 variables, one is String and one is int. I want to know how can i construct an array of Testclass which should have the corresponding variables in it.

I have the following code.

public class Testclass {

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

Testclass(Testclass1[] tc1){

    for(int i=0; i<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<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;
    }

Method in Function class is as follows:

public Testclass[] getTestClass(){

 //What to do?

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:19:08+00:00Added an answer on June 14, 2026 at 1:19 pm

    Make attributes of the class TestClass be arrays. Create getters and setters if necessary. Create constructor initializer that accepts values or TestClass1 and initializes TestClass2 array. Create default constructor for TestClass2.

    TestClass(TestClass1[] tc1, String attrName){
    
        tc = tc1;
        this.attrName = attrName; 
        if (tc != null) {
          tc2 = new TestClass2[tc.length];
          for(int i = 0; i< tc.length; i++) {
            TestClass2 t2c = new TestClass2(tc[i].getElements()); //this.tc.elements will   return an Array of SomeClass which is not implemented by me.
            tc2[i] = t2c;
          }
       }
    }
    
    /**
     * Returns the Testclass2 Array
     */
    public TestClass2[] getTestClass2(){
    
      //What to do ?? 
      return tc2;
    }
    
    class TestClass2 {
       /**
        * Default constructor
        */ 
       TestClass2(){}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to wrap my head around this FXCop violation DoNotDeclareReadOnlyMutableReferenceTypes MSDN:
Trying to wrap my head around JTA and have arbitrarily chosen Bitronix as the
I am trying to wrap my head around Apache Camel, which appears to be
I am trying to wrap a generated series of elements that are created on
Trying to wrap my head around the apple design scheme. I have a UIViewController
I'm trying to wrap my head around this to make the correct design decisions.
I've been trying to wrap my head around this issue: How to create a
I'm trying to wrap my head around this, but I seem to go in
Trying to wrap my head around this function any_name($div,$width = false){ if($width){ $add_style ='
I'm trying to wrap my head around asp.net. I have a background as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.