Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ɾ³ýList ÖеÄÖظ´Êý¾Ý

1. Ñ­»·listÖеÄËùÓÐÔªËØÈ»ºóɾ³ýÖظ´
public static List removeDuplicate(List list) {
for ( int i = 0 ; i < list.size() - 1 ; i ++ ) {
for ( int j = list.size() - 1 ; j > i; j -- ) {
if (list.get(j).equals(list.get(i))) {
list.remove(j);
}
}
}
return list;
}
2. ͨ¹ýHashSetÌß³ýÖظ´ÔªËØ
public static List removeDuplicate(List list) {
HashSet h = new HashSet(list);
list.clear();
list.addAll(h);
return list;
}
ÔÚgroovyÖе±È»Ò²¿ÉÒÔʹÓÃÉÏÃæµÄÁ½ÖÖ·½·¨, µ«groovy×Ô¼ºÌṩÁËunique·½·¨À´È¥³ýÖظ´Êý¾Ý
def list = [1, 2, 3, 2, 4, 1, 5]
list.unique() // [1, 2, 3, 4, 5]


Ïà¹ØÎĵµ£º

C++ºÍJavaµÄ¶à¼Ì³Ð


¶à¼Ì³Ð£º
C++ÖеÄÀà¿ÉÒÔÖ±½ÓʵÏÖ¶à¼Ì³Ð È磺class D:public A,public B,public C{……};
JavaÖв»ÄÜÖ±½ÓʵÏÖÕâÑùµÄ¶à¼Ì³Ð£¬µ«ÊÇ¿ÉÒÔÓýӿڣ¨interface£©À´¼ä½ÓʵÏÖ È磺
public class A{ ……}
public interface C{
¡¡¡¡public void c1();
¡¡¡¡public void c2();
}
public class C exten ......

Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄÒ»ÖÖ×ö·¨

Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄ½â·¨£¬ÍøÉÏÓв»ÉÙÌÖÂÛ¡£ÕâÀïÎÒÒ²¸ø³öÒ»ÖÖÎÒ×Ô¼ºµÄ´¦Àí£¬»ù±¾Ô­Àí»¹ÊÇͳ¼ÆÒª½ØÈ¡µÄ×Ö½ÚÊýÖÐÊDZíʾºº×ÖµÄ×Ö½ÚÊýÊÇ·ñÊÇżÊý¸ö£¬¼´ÊÇ·ñ¸ÕºÃ°üÀ¨ÁËÍêÕûµÄºº×Ö¡£
/**
 * ±à³Ì£º±àдһ¸ö½ØÈ¡×Ö·û´®µÄº¯Êý£¬ÊäÈëΪһ¸ö×Ö·û´®ºÍ×Ö½ÚÊý£¬Êä³öΪ°´×Ö½Ú½ØÈ¡µÄ×Ö·û´®¡£ µ«ÊÇÒª±£Ö¤ºº×Ö²»±»½Ø°ë¸ ......

java ·´Éä

Ò»¡¢Ê²Ã´ÊÇ·´É䣺
      ·´ÉäµÄ¸ÅÄîÊÇÓÉSmithÔÚ1982ÄêÊ×´ÎÌá³öµÄ£¬Ö÷ÒªÊÇÖ¸³ÌÐò¿ÉÒÔ·ÃÎÊ¡¢¼ì²âºÍÐÞ¸ÄËü±¾Éí״̬»òÐÐΪµÄÒ»ÖÖÄÜÁ¦¡£ÕâÒ»¸ÅÄîµÄÌá³öºÜ¿ìÒý·¢Á˼ÆËã»ú¿ÆѧÁìÓò¹ØÓÚÓ¦Ó÷´ÉäÐÔµÄÑо¿¡£ËüÊ×Ïȱ»³ÌÐòÓïÑÔµÄÉè¼ÆÁìÓòËù²ÉÓÃ,²¢ÔÚLispºÍÃæÏò¶ÔÏó·½ÃæÈ¡µÃÁ˳ɼ¨¡£ÆäÖÐLEAD/LEAD++ ¡¢OpenC+ ......

JavaÖеġ°==¡±ºÍequal()

Integer n1 = new Integer(1);
Integer n2 = new Integer(1);
System.out.println(n1==n2); // false
Integer n1 = new Integer(3);
Integer n2 = new Integer(3);
System.out.println(n1.equals(n2)); //true

equals()ĬÈÏÒ²ÊDZȽÏreference£¬µ«ÊÇJavaÖеÄclass¸²¸ÇÁËequals()·½·¨ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ