This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes New to prog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "New to prog" Watch "New to prog" New topic
Author

New to prog

Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
IF objects arent stored in an array and i would like to print all of them to screen using a loop or it cannot be done can it?
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

I'm a little bit confused. Is this a hypothetical question, or do you have a concrete example that you could share?

You could store objects in a Collection (such as a LinkedList, which does not use an array to store the objects) and then iterate over the collection. So the answer is Yes.

But if you are asking whether Java has an accessible "Object Registry" listing all objects that have been created, the answer is No. If you create an object, in order to get the object you have to maintain a reference somewhere:

- as a member variable in another object
- in an array
- in a Collection


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Randy, that is cool. so Prog is really cool. There are some great band in Prog Rock, like my favorites Rush, Dream Theater, Saga, Marillion, and Spock's Beard.

Have fun.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to prog