集册 Java实例教程 替换数组中的值

替换数组中的值

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

452
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
替换数组中的值


//package com.nowjava;/*来 自 N o w  J a v a  .   c o m*/

import java.util.Arrays;


public class Main {

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

        int[] arr = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };

        int startIndex = 2;

        int endIndex = 2;

        int value = 2;

        System.out.println(java.util.Arrays.toString(replaceArray(arr,

                startIndex, endIndex, value)));

    }/*来 自 时代Java公众号*/


    public static int[] replaceArray(int[] arr, int startIndex,

            
展开阅读全文