Skip to main content

initializing boolean arrays (newbie question)

3 replies [Last post]
justsomeguy805
Offline
Joined: 2007-07-26

is it possible to initialize a boolean array so that all its elements are true in one statement? The array will have a high index so i don't want to have to specify each element manually( {true, true, true......} ).

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fat_aido
Offline
Joined: 2009-07-06

I also found this very helpful, u are most wise. :-)

pietblok
Offline
Joined: 2003-07-17

boolean [] array = new boolean [1000];
java.util.Arrays.fill(array,true);

Hope this helps.

justsomeguy805
Offline
Joined: 2007-07-26

thanks a lot!