集册 Java实例教程 深填充数组元素

深填充数组元素

欢马劈雪     最近更新时间:2020-01-02 10:19:05

516
深填充数组元素
/**时   代     Java  公  众  号 - nowjava.com**/

//package com.nowjava;


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);

    }


    public static void deepFill(double[] arr, double filler) {

        for (int i = 0; i < arr.length; i++) {

            arr[i] = filler;

        }

    }
/* 来自 nowjava.com*/

    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+
展开阅读全文