List of usage examples for java.util Arrays fill
public static void fill(Object[] a, Object val)
From source file:Main.java
public static void main(String[] argv) throws Exception { byte[] byteArr = new byte[10]; byte byteFillValue = (byte) 0xFF; Arrays.fill(byteArr, byteFillValue); }
From source file:Main.java
public static void main(String[] argv) throws Exception { double[] doubleArr = new double[10]; double doubleFillValue = -1; Arrays.fill(doubleArr, doubleFillValue); }
From source file:Main.java
public static void main(String[] argv) throws Exception { boolean[] booleanArr = new boolean[10]; boolean booleanFillValue = false; Arrays.fill(booleanArr, booleanFillValue); }
From source file:Main.java
public static void main(String[] args) { boolean arr[] = new boolean[] { true, true, false }; System.out.println(Arrays.toString(arr)); // using fill for placing false Arrays.fill(arr, false); System.out.println(Arrays.toString(arr)); }
From source file:MainClass.java
public static void main(String[] a) { byte array[] = new byte[10]; // Arrays.fill(array, 4); // illegal for (int i : array) { System.out.println(i);//from w w w . ja va2s . c om } Arrays.fill(array, (byte) 4); // Okay for (int i : array) { System.out.println(i); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { boolean[] booleanArr = new boolean[10]; boolean booleanFillValue = false; Arrays.fill(booleanArr, booleanFillValue); }
From source file:Main.java
public static void main(String[] args) { // initializing char array char arr[] = new char[] { 'a', 'b', 'c' }; System.out.println(Arrays.toString(arr)); // using fill for placing z Arrays.fill(arr, 'z'); System.out.println(Arrays.toString(arr)); }
From source file:Main.java
public static void main(String[] args) { // initializing long array long arr[] = new long[] { 1, 6, 4, 49, 227 }; System.out.println(Arrays.toString(arr)); // using fill for placing 12 Arrays.fill(arr, 12); System.out.println(Arrays.toString(arr)); }
From source file:Main.java
public static void main(String[] args) { // initializing short array short arr[] = new short[] { 1, 2, 3, 4, 13 }; System.out.println(Arrays.toString(arr)); // using fill for placing 23 Arrays.fill(arr, (short) 23); System.out.println(Arrays.toString(arr)); }
From source file:Main.java
public static void main(String[] args) { // initializing float array float arr[] = new float[] { 1f, 2f, 3f, 4f, 5f }; System.out.println(Arrays.toString(arr)); // using fill for placing 12 Arrays.fill(arr, 12f); System.out.println(Arrays.toString(arr)); }