Fill 10-element array with 7s - Java java.util

Java examples for java.util:Arrays

Description

Fill 10-element array with 7s

Demo Code

import java.util.Arrays;

public class Main 
{
   public static void main(String[] args)
   {//from   w  w w. j  a v a  2  s.  c o m
     // fill 10-element array with 7s
     int[] filledIntArray = new int[10]; 
     Arrays.fill(filledIntArray, 7); 
     displayArray(filledIntArray, "filledIntArray");
   } 

   // output values in each array
   public static void displayArray(int[] array, String description)
   {     
      System.out.printf("%n%s: ", description);

      for (int value : array)
         System.out.printf("%d ", value);
   } 
}

Result


Related Tutorials