Results 1 to 6 of 6
  1. #1
    99Cookies is offline Member
    Join Date
    Mar 2014
    Posts
    4
    Rep Power
    0

    Default Return an array containt all the object name of a class...

    Hi!

    I need to return all the object name of one class in an array. I have a class named country, and other classes with athletes and medals etc. I need to do a method that list an array with all the countries that participate, so all the objects created with the class country (i.e canada.country, usa.country, etc). Is there a way I can retreive them?

    Thanks!

    EDIT: mispells

  2. #2
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    162
    Rep Power
    2

    Default Re: Return an array containt all the object name of a class...

    Return the String of the name of the countries. There's not much we can do to help unless you post some sample code of what you are trying so far.

  3. #3
    99Cookies is offline Member
    Join Date
    Mar 2014
    Posts
    4
    Rep Power
    0

    Default Re: Return an array containt all the object name of a class...

    Yes, sorry!

    Here it goes

    public Country[] getCountry{

    int count = (I need to find a way to know how many object of the class Country there is);
    Country[] tab = new Country[count];

    for(int i = 0; i<count; i++){

    tab[i] = first object created with the class Country;

    }


    return tab;
    }

    I just wanted to know if there is a way I can get the name of the objects made with the class country, thats it!
    Last edited by 99Cookies; 03-16-2014 at 06:23 PM.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default Re: Return an array containt all the object name of a class...

    edit: the question is not what it seemed to be
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    99Cookies is offline Member
    Join Date
    Mar 2014
    Posts
    4
    Rep Power
    0

    Default Re: Return an array containt all the object name of a class...

    OOPS, not as a string, but as an object in each array of the array tab**

  6. #6
    99Cookies is offline Member
    Join Date
    Mar 2014
    Posts
    4
    Rep Power
    0

    Default Re: Return an array containt all the object name of a class...

    Nevermind I found a way, thanks!

Similar Threads

  1. adding an object to an array in another class
    By jwood in forum New To Java
    Replies: 92
    Last Post: 08-02-2013, 09:59 PM
  2. Instantiating an array with object of another class
    By AMCNovember in forum New To Java
    Replies: 11
    Last Post: 02-18-2012, 05:29 PM
  3. Replies: 0
    Last Post: 10-03-2011, 08:27 AM
  4. Replies: 1
    Last Post: 06-24-2011, 06:36 AM
  5. Can we generate an array for class object?
    By gaurav2211 in forum Advanced Java
    Replies: 4
    Last Post: 03-21-2009, 04:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •