Example usage for java.util Arrays fill

List of usage examples for java.util Arrays fill

Introduction

In this page you can find the example usage for java.util Arrays fill.

Prototype

public static void fill(Object[] a, Object val) 

Source Link

Document

Assigns the specified Object reference to each element of the specified array of Objects.

Usage

From source file:Main.java

public static void main(String[] a) {
    int array[] = new int[10];
    Arrays.fill(array, 100);
    for (int i : array) {
        System.out.println(i);//from   www .j a v a 2s .  c  o  m
    }
    Arrays.fill(array, 3, 6, 50);
    for (int i : array) {
        System.out.println(i);
    }
}

From source file:FillTest.java

public static void main(String args[]) {
    int array[] = new int[10];
    Arrays.fill(array, 100);
    for (int i = 0, n = array.length; i < n; i++) {
        System.out.println(array[i]);
    }//from   w w  w . j a va2  s .  c  o m
    System.out.println();
    Arrays.fill(array, 3, 6, 50);
    for (int i = 0, n = array.length; i < n; i++) {
        System.out.println(array[i]);
    }
    byte array2[] = new byte[10];
    Arrays.fill(array2, (byte) 4);

    System.out.println();
    Date array3[] = new Date[10];
    Date anObject = new Date();
    Arrays.fill(array3, "Help");
    anObject.setYear(102);
    for (int i = 0, n = array3.length; i < n; i++) {
        System.out.println(array3[i]);
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int[] intArr = new int[10];
    int intFillValue = -1;
    Arrays.fill(intArr, intFillValue);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    long[] longArr = new long[10];
    long longFillValue = -1;
    Arrays.fill(longArr, longFillValue);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    char[] charArr = new char[10];
    char charFillValue = 'c';
    Arrays.fill(charArr, charFillValue);
}

From source file:MainClass.java

public static void main(String[] arg) {
    double[] data = new double[50]; // An array of 50 values of type double
    Arrays.fill(data, 1.0); // Fill all elements of data with 1.0

    for (int i = 0; i < data.length; i++) { // i from 0 to data.length-1
        System.out.println(data[i]);
    }/*from  w  w w.j a v  a2  s. c  o  m*/

}

From source file:MainClass.java

public static void main(String[] arg) {
    double[] data = new double[50]; // An array of 50 values of type double
    Arrays.fill(data, 1.0); // Fill all elements of data with 1.0

    for (double d : data) {
        System.out.println(d);//w w w  . j  ava 2  s  .  co m
    }

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    short[] shortArr = new short[10];
    short shortFillValue = 2;
    Arrays.fill(shortArr, shortFillValue);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    float[] floatArr = new float[10];
    float floatFillValue = -1;

    Arrays.fill(floatArr, floatFillValue);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    String[] StringArr = new String[1];
    String StringFillValue = "";
    Arrays.fill(StringArr, StringFillValue);
}