packagelist;importjava.util.Enumeration;importjava.util.Hashtable;publicclassEnums{publicstaticString[]copare(String[]a,String[]b){Hashtablehashtable=newHa...
package list;
import java.util.Enumeration;
import java.util.Hashtable;
public class Enums {
public static String[] copare(String[] a,String[] b){
Hashtable hashtable=new Hashtable();
Hashtable hashtable_new=new Hashtable();
for(int i=0;i
hashtable.put(b[i], b[i]);
}
for (int i = 0; i < a.length; i++) {
if(!hashtable.contains(a[i])){
hashtable_new.put(a[i], a[i]);
}
}
Enumeration enumeration=hashtable_new.keys();
int i=0;
String []c=null;
while (enumeration.hasMoreElements()) {
c[i] = (String) enumeration.nextElement();
i++;
}
return c;
}
public static void main(String[] args) {
String []A={"a","b","cc","dd"};
String []B={"a","b"};
String []C=copare(A, B);
for (int i = 0; i < C.length; i++) {
System.out.println(C[i]);
}
}
}
你好,你的回答我看到了,正确了,很感谢,可是为什么啊????
展开