日期:2014-05-20 浏览次数:20715 次
public class Test { public static void main(String[] args) { int[] a = {3,4,5,6}; int[] b = {3,4,7,8}; for (int i=0; i<b.length; i++) { Boolean flag=false; for(int j=0;j<a.length;j++){ if(b[i]==a[j]){ flag=true; } } if(flag==false){ System.out.println(b[i]); } } } }
------解决方案--------------------
int[] a = {3,4,5,6}; int[] b = {3,4,6,7,8,9,1,2,5}; int j; for (int i=0; i<b.length; i++) { for (j=0; j<a.length; j++) if (a[j]==b[i]) break; if (j==a.length) System.out.println(b[i]); }