Object Array Class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cshnab
    New Member
    • May 2012
    • 1

    Object Array Class

    Hi all.
    I kindly want your help here.

    As a newbie in OOP, I am trying to understand how the language reacts.

    What I want to do is initialize an object array of another class.

    What I am trying to say is :

    Class xx
    Code:
    foo[] foox = new foo[9] 
    foox[0] = new foo("value here","value here");
    
    //Class foo has the variables . IE string name; - string something;
    After a 5hour search and total confusion,the only way this works is this :
    Code:
    foo[] foox;
    
    public xx()
    {
      foox = new foo[9];
      foox[0] = new foo("value","value");
      foox[1] = new foo(etc etc);
    
    //etc 
    
    }
    Is this the only way ? And how can I print the objects when I need them in my Main class ?? Thank you in advance.
    Last edited by Frinavale; May 30 '12, 01:31 PM. Reason: Added code tags.
Working...