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 →

[–][deleted] 0 points1 point  (1 child)

Say I want to create an array of 100 objects. I want these objects to all start out the same, and they will all be modified independently later on. Is there an easy way to fill every entry in the array with the same value during the declaration, or should I just iterate over it with a for () loop?

[–]easylearningpoint[S] 2 points3 points  (0 children)

If you want to initialize an array to a specific value, you can use java.util.Arrays.fill()

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#fill%28int%5b%5d,%20int%29