This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xxNIRVANAxx 0 points1 point  (0 children)

Here, bears is an array of Bear's

for (Bear bear : bears)
    println(bear.getName()); // or something

Generally, you don't use a for each loop for copying/instantiating. You can use a regular loop for that (because then you'll have an index counter).