Java examples for Collection Framework:Array Fill
deep Fill array element
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { double[] arr = new double[] { 34.45, 35.45, 36.67, 37.78, 37.0000, 37.1234, 67.2344, 68.34534, 69.87700 }; double filler = 2.45678; deepFill(arr, filler);// w w w .j av a 2 s . c om } public static void deepFill(double[] arr, double filler) { for (int i = 0; i < arr.length; i++) { arr[i] = filler; } } public static void deepFill(double[][] arr, double filler) { for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { arr[i][j] = filler; } } } public static void deepFill(double[][][] arr, double filler) { for (int i = 0; i < arr.length; i++) { if (arr[i] == null) { continue; } for (int j = 0; j < arr[i].length; j++) { if (arr[i][j] == null) { continue; } for (int k = 0; k < arr[i][j].length; k++) { arr[i][j][k] = filler; } } } } }