转载于 : 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