Java 数组 之 一维数组 修改 元素

http://www.verejava.com/?id=16992660057227

/**
     修改scores数组索引index位置的值为value
*/
import java.util.Scanner;

public class ArrayUpdate {
    
    public static void main(String[] args) {
        //一维数组的定义和初始化
        int[] scores = { 90, 70, 50, 80, 60, 85 };
        System.out.println("请输入要修改的索引位置 index : ");
        Scanner in = new Scanner(System.in);
        int index = in.nextInt();
        System.out.println("请输入要修改的值 value : ");
        int value = in.nextInt();
        //修改
        scores[index] = value;
        //打印输出scores
        for (int i = 0; i < scores.length; i++) {
            System.out.print(scores[i] + ",");
        }
    }
}

http://www.verejava.com/?id=16992660057227

上一篇:linux下/dev/shm的大小引发ORA-00845: MEMORY_TARGET not supported on this system 2015-06-16 08:55:50


下一篇:Perl快捷删除数组重复元素