Quick array question

Is there a nice and quick way to set a default value of all array elements? Say, I initialize a string array of 30 elements and all of them would initially have a value "foobar" for example. Or is for loop the only way to do that?
[237 byte] By [Reea] at [2007-10-2 8:11:28]
# 1

> Is there a nice and quick way to set a default value

> of all array elements? Say, I initialize a string

> array of 30 elements and all of them would initially

> have a value "foobar" for example. Or is for loop the

> only way to do that?

As far as I know a loop of some kind is required although if you need many identical arrays then the others can be created with the cloning facility.

Gargoylea at 2007-7-16 22:07:38 > top of Java-index,Java Essentials,New To Java...
# 2
import java.util.Arrays;...Arrays.fill(myArray, myValue);
jsalonena at 2007-7-16 22:07:38 > top of Java-index,Java Essentials,New To Java...
# 3
Thanks this was useful.
Reea at 2007-7-16 22:07:38 > top of Java-index,Java Essentials,New To Java...