import java.util.*;
public class input { /**
* @100abcnet
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] num = new int[5];// 定义长度为5的int数组
Scanner sc = new Scanner(System.in);// 实例化控制台输入方法 int i,a,b,c;
System.out.println("请输入数.."); for (i = 0; i < num.length; i++) {
num[i] = sc.nextInt();// 循环从控制台输入字符赋值给num数组
}
for (i = 0; i < num.length; i++) {
System.out.print(num[i] + " ");
}
System.out.println("请输入要插入第几位");
a=sc.nextInt();
System.out.println("请输入要插入的数字");
c=sc.nextInt();
for(b=num.length;b>a;b--){
num=num[b-1];
num[a]=c;
}
[b]num.length=num.length+1;/++++++说这行the final field array.length cannot be assigned++++++++++++++
for (i = 0; i < num.length; i++) {
System.out.print(num[i] + " ");
}
}
}请指教....
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货