Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

How to initialize an array of boolean datatype and assign false value to all the indices of the array?

1 Answer

0 votes
by (13.1k points)

You can do it in two ways:

Boolean[] arr=new boolean[size];

This would set all the values to false by default

Boolean[] arr=new boolean[size];

Arrays.fill(arr,Boolean.false);

This would set all the values to false explicitly.

Related questions

0 votes
1 answer
asked Feb 7, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
asked Mar 11, 2021 in Java by Jake (7k points)
0 votes
1 answer
0 votes
1 answer
asked Sep 23, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer

Browse Categories

...