Java Array class fill(long[] a, long val) example
Array class fill(long[] a, long val)method example
Array class fill(long[] a, long val) method example. This example shows you how to use fill(long[] a, long val) method.This method Assigns the specified long value to each element ofthe specified array of longs.
Here is the code:-
/**
* @Program that Assigns the specified long value to each element of
* the specified array of longs.
* fill13Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class fill13Array {
public static void main(String[] args) {
//creating a long array
long b[] = {12,12,34,56,78,90,98};
System.out.print("The original array is:-");
for (int i = 0; i < b.length; i++) //Display the long array
{
System.out.print("\t"+b[i]);
}
System.out.println();
// Assigns the specified long value to each element of the
//specified array of longs.
Arrays.fill(b,0);
System.out.print("The Changed array is:-");
for (int i = 0; i < b.length; i++)
//Display the Changed long array
{
System.out.print("\t"+b[i]);
}
}
} |
Output of the program:-
The original array is:- 12 12 34 56 78 90 98
The Changed array is:- 0 0 0 0 0 0 0 |
|