标签:package oid 删除 java util static can int scanner
package test;
import java.util.Scanner;
public class Deletearr {
public static void deletearr(){
Scanner sc=new Scanner(System.in);
int[] arr={1,3,5,7,9,8,4};
int[] newarr=new int[arr.length-1];
System.out.println("请输入你想删除数组中的第几个数据:");
int n=sc.nextInt();
for(int i=0;i<newarr.length;i++){
if(i>=n){
newarr[i]=arr[i+1];
}else{
newarr[i]=arr[i];
}
}
System.out.println("新数组为:");
for(int num:newarr){
System.out.print(num);
}
}
public static void main(String[] args) {
deletearr();
}
}
标签:package oid 删除 java util static can int scanner
原文地址:http://www.cnblogs.com/sxx1993/p/7542441.html