public void testNum() { int[] num1 = { 3, 7, 8, 9, 71, 72, 73 }; int[] num2 = { 7, 6, 5, 4, 3 }; ArrayList al = new ArrayList(); //把数组1中与数组2中不重复的数值加入arraylist中 for (int r = 0; r < num1.length; r++) { int sign = 0; for (int s = 0; s < num2.length; s++) { if (num1[r] == num2[s]) {
sign = 1; } } if (sign == 0) { al.add(num1[r]); } } int[] num = new int[al.size() + num2.length];
for (int s = 0; s < al.size(); s++) { num[s] = (int) al.get(s); // System.out.println("=====>al"+s+"="+al.get(s));
}
for (int j = al.size(), k = 0; j < num.length && k < num2.length; j++, k++) { num[j] = num2[k]; }
//把num重新冒泡排序 for (int i = 0; i < num.length; i++) { for (int k = 0; k < num.length - 1; k++) { if (num[k] > num[k + 1]) { int temp = num[k]; num[k] = num[k + 1]; num[k + 1] = temp;
} } }
