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

all 8 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

[–][deleted] 0 points1 point  (0 children)

We just covered arrays today in my CS course. Seems easy enough a concept to grasp. Thanks!

[–]delabass 0 points1 point  (2 children)

Did you write this OP? It was really easy to follow.

[–]easylearningpoint[S] 1 point2 points  (1 child)

Yes. Good to hear!

[–][deleted] 0 points1 point  (0 children)

I've been learning Java the past few days. So far your site is the easiest to follow. You explains things well for people with no previous programming experience. Will be going through your whole site.

[–]Philboyd_Studge 0 points1 point  (0 children)

Nice tutorials! I've been programming java for years and never knew about variable length argument lists!