Prasanna Raman wrote:Hello Jeff,
I don't want to find anything about which class the student is in.
I just want a method that can print the list of names of all Student objects in that class.
Prasanna Raman wrote:What if the class has only one attribute name and that I want to print the names of all student objects?
Prasanna Raman wrote:I am just trying to add a method that prints
A, B as the output.
Prasanna Raman wrote:Thank you, Jeff! Yes, I tried out the iterator and was able to make it work.
But, if you want to read all the objects' names before you store those objects in a collection, is there a way to do it?
Prasanna Raman wrote:I know how to read an object's fields using the dot operator. This is a dumb question, but please bear with me.
I know we can use iterator when the objects are stored on a collection. But where are they stored when we just create them and before we add them to any collection? Is there any way to print all the names before adding the objects to any collection?
Prasanna Raman wrote:Now, what are we doing when we are storing these in a collection? Are we just storing all the foo variables in a collection because we can then use the iterator etc. which gives us a way to loop through all the objects easily and because there is no other way for us to do it other than using a collection? Or, for what other reasons do we store in collection?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |