java¼¯ºÏSet²Ù×÷
package Sets;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
/**
* java¼¯ºÏ²Ù×÷
*
* @author baby69yy2000
*
*/
public class Sets {
/** Çó²¢¼¯ */
public static <T> Set<T> union(Set<T> setA, Set<T> setB) {
Set<T> setUnion;
if (setA instanceof TreeSet)
setUnion = new TreeSet<T>();
else
setUnion = new HashSet<T>();
Iterator<T> iterA = setA.iterator();
while (iterA.hasNext())
setUnion.add(iterA.next());
Iterator<T> iterB = setB.iterator();
while (iterB.hasNext())
setUnion.add(iterB.next());
return setUnion;
&n
Ïà¹ØÎĵµ£º
ijЩÍøÕ¾ÔÊÐíÈí¼þ¿ª·¢ÉçÍÅͨ¹ý·¢²¼¿ª·¢ÕßÖ¸ÄÏ¡¢°×ƤÊé¡¢FAQs¡¾³£¼ûÎÊÌâ½â´ð¡¿ºÍÔ´´úÂëÒÔʵÏÖÐÅÏ¢µÄ¹²Ïí¡£Ëæ×ÅÐÅÏ¢Á¿µÄÔö³¤£¬ºÍ¼¸¸ö¿ª·¢Õß¹±Ï׳ö×Ô¼ºµÄ֪ʶ¿â£¬ÓÚÊÇÍøÕ¾ÌṩËÑË÷ÒýÇæÀ´ËÑË÷Õ¾µãÉÏÏÖÓеÄËùÓÐÐÅÏ¢¡£ËäÈ»ÕâЩËÑË÷ÒýÇæ¶ÔÎı¾ÎļþµÄËÑË÷¿ÉÒÔ×öµÄºÜºÃ£¬µ«¶Ô¿ª·¢ÕßËÑË÷Ô´´úÂë×öÁ˱ȽÏÑϸñµÄÏÞÖÆ¡£ËÑË÷ÒýÇæÈÏΪԴ´úÂë ......
µÚÒ»ÕÂ ÒýÑÔ
(By wind5shy£ºhttp://blog.csdn.net/wind5shy)
µÚ¶þÕ ´´½¨ºÍÏú»Ù¶ÔÏó
(By wind5shy£ºhttp://blog.csdn.net/wind5shy)
µÚ1Ìõ£º¿¼ÂÇÓþ²Ì¬¹¤³§·½·¨´úÌæ¹¹Ô캯Êý
ºÃ´¦£º
¾²Ì¬¹¤³§·½·¨ÓÐÃû×Ö£¬±í´ï¸üÇå³þ¡£
²»Ðè´´½¨ÐµĶÔÏó¡£
¿ÉÒÔ·µ»ØÔ·µ»ØÀàÐ͵Ä×ÓÀàÐͶÔÏó¡£Ó¦Óãº1.·µ»ØÀàÐͶ¨ÒåΪ½ ......
1¡¢½«String/StringBuffer±äÁ¿µÄÖµÖÃΪnull£¬ÔòÆäËùÕ¼ÄÚ´æ»áºÜ¿ì±»»ØÊÕ¡£
2¡¢ÔËÐйý³ÌÖнöÒÀÀµÓÚÊäÈë²ÎÊýµÄ·½·¨£¬ÈçÊýѧ·½·¨£»¾²Ì¬³ÉÔ±±äÁ¿³£Îª¶¨Òå³£Êý£¬ÓÃÏÞ¶¨´Êpublic static final£»¾²Ì¬³ÉÔ±±äÁ¿¿É½ÚÊ¡ÄÚ´æ¡£
3¡¢½Ó¿Ú£ºÈôÓÐÐèÍê³É³éÏóµÄ¶¯×÷»ò¾ßÓиÅÄîÐÔµÄÊôÐÔ£¬ÔòÔÚ½Ó¿ÚÖж¨Òå¸Ã¶¯×÷»ò¸ÅÄÔÚʵÏָýӿڵÄÀàÖоßÌå» ......
Õ⼸ÌìÍøÂçÓÐÎÊÌ⣬ËùÒÔ½ñÌìÒ»Æð×ܽá³öÀ´
ÀàµÄС½á
1£¬Àà³éÏóÁËËùÓоßÓÐÒ»¶¨¹²ÐÔµÄʵÌåµÄ¹²Í¬Ìسơ£Ò»¸öÀàÖУ¬±äÁ¿ÓÃÀ´±íʾÊôÐÔ£¬·½·¨ÓÃÀ´±íʾ¹¦ÄÜ£¬Àà°ÑÊý¾ÝºÍ¶ÔÊý¾ÝµÄ²Ù×÷·â×°³ÉÒ»¸öÕûÌå¡£³ÌÐòÓïÑÔÖУ¬Í¨¹ýÀà´´½¨¶ÔÏó¡£
2£¬¹¹Ô캯ÊýµÄ×÷ÓÃÔÚÓÚÉùÃ÷ÀàµÄ¶ÔÏóºó£¬ÎªÆä·ÖÅä´¢´æµ¥Ôª£¬¼´´´½¨ÊµÀý¡£
3,²»Í¬¶ÔÏóµÄʵÀý±äÁ¿½« ......
À´Ô´: http://xfshiyuan.blog.sohu.com/100496073.html
ÓÉÓÚͬһ½ø³ÌµÄ¶à¸öÏ̹߳²ÏíͬһƬ´æ´¢¿Õ¼ä£¬ÔÚ´øÀ´·½±ãµÄͬʱ£¬Ò²´øÀ´ÁË·ÃÎʳåÍ»Õâ¸öÑÏÖصÄÎÊÌâ¡£JavaÓïÑÔÌṩÁËרÃÅ»úÖÆÒÔ½â¾öÕâÖÖ³åÍ»£¬ÓÐЧ±ÜÃâÁËͬһ¸öÊý¾Ý¶ÔÏ󱻶à¸öÏß³Ìͬʱ·ÃÎÊ¡£
¡¡¡¡ÐèÒªÃ÷È·µÄ¼¸¸öÎÊÌ⣺
¡¡¡¡1)synchronized¹Ø¼ü×Ö¿É ......