Java Array class fill(boolean[] a, boolean val) example
Array class fill(boolean[] a, boolean val) method example
Array class fill(boolean[] a, boolean val)method example. This example shows you how to use fill(boolean[] a, boolean val)method.This method Assigns the specified boolean value to each element of the specified array of booleans.
Here is the code:-
/**
* @Program that Assigns the specified boolean value to each element of the
* specified array of booleans.
* fillArray.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class fillArray {
public static void main(String[] args) {
//Declaring a boolean array
boolean b[]={true,false,true,false,true,true};
//Assigns the specified boolean value to each element of the specified array
Arrays.fill(b, true);
for(int i=0;i<b.length;i++)
//Displays the changed array
System.out.println(b[i]);
}
} |
Output of the program:-
true
true
true
true
true
true |
|