Java从数组中剔除指定元素

Java从数组中删除指定元素

	/**
	 * 已知一组有序数列,输入任意数,从这个数列中删除这个数, 显示删除后数列
	 */
	public static void main(String[] args) {
		int num[] = new int[] { 1, 2, 3, 4, 5, 6, 7 };
		int m = 7;
		int[] copy = new int[num.length-1];
		int j = 0;
		for (int i = 0; i < num.length; i++) {
			if (m == num[i]) {
				i = i + 1;
			}
			if(i<num.length){
				copy[j]=num[i];
			}
			 j++;
		}
		for (int i = 0; i < copy.length; i++) {
			System.out.print(copy[i]+" ");
		}
	}