Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to prog

 
Tempora Telora
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic