javaµÚ9Ìì¿ÎÌÃ±Ê¼Ç (Set)
1¡¢set¼¯ºÏÊÇ×î¼òµ¥µÄÒ»ÖÖ¼¯ºÏ£¬¼¯ºÏÖв»°´Ö¸¶¨µÄ·½Ê½ÅÅÐò£¬²¢ÇÒûÓÐÖظ´¶ÔÏó¡£
2¡¢set½Ó¿ÚÖ÷ÒªÓÐÁ½¸öʵÏÖÀࣺHashSetºÍTreeSet
(1)HashSet:ÊÇ°´ÕÕ¹þÏ£Ëã·¨À´½øÐдæÈ¡¼¯ºÏÖеĶÔÏ󣬴æÈ¡µÄËٶȱȽϿ졣
(2)TreeSet£ºÊµÏÖÁËSortedSet½Ó¿Ú£¬¾ßÓÐÅÅÐòµÄ¹¦ÄÜ¡£
3¡¢HashSetÀàÊÇ°´ÕÕ¹þÏ£Ëã·¨À´´æÈ¡¼¯ºÏÖеĶÔÏ󣬾ßÓÐÁ¼ºÃµÄ´æÈ¡ºÍ²éÕÒÐÔÄÜ¡£µ±Ïò¼¯ºÏÖмÓÈëÒ»¸ö¶ÔÏóʱ£¬HashSet
»áµ÷ÓöÔÏóµÄHashCode()·½·¨À´»ñµÃ¹þÏ£Â룬Ȼºó¸ù¾ÝÕâ¸ö¹þÏ£Âë½øÒ»²½¼ÆËã³ö¶ÔÏóÔÚ¼¯ºÏÖеĴæ·ÅλÖá£
4¡¢ÔÚObjectÀàÖж¨ÒåÁËHashCode()ºÍEquals()·½·¨£¬ObjectÀàµÄequals()·½·¨°´ÕÕÄÚ´æµØÖ·±È½Ï¶ÔÏó£¬Òò´ËÈç¹û
object1.equals(object2)Ϊtrue,Ôò±íÃ÷object1±äÁ¿ºÍObject2±äÁ¿Êµ¼ÊÉÏÒýÓõÄÊÇͬһ¸ö¶ÔÏó£¬ÄÇôobject1
Óëobject2µÄ¹þÏ£ÂëÒ²ÊÇÏàͬµÄ¡£
5¡¢Á½ÖÖÅÅÐò£º
(1)×ÔÈ»ÅÅÐò:TreeSetµ÷ÓöÔÏóµÄcompareTo()·½·¨±È½Ï¼¯ºÏÖжÔÏóµÄ´óС£¬È»ºó½øÐÐÉýÐòÅÅÁУ¬ÕâÖÖÅÅÐòµÄ·½Ê½³ÆΪ×ÔÈ»ÅÅÐò¡£
Comparable½Ó¿ÚÓÐÒ»¸öcompareTo(Object obj)·½·¨£¬·µ»ØµÄÊÇÕûÊýÀàÐÍ¡£
¶ÔÓÚ±í´ïʽx.compareTo(y),
Èç¹û·µ»ØֵΪ0£¬Ôò±íʾxºÍyÏàµÈ;
Èç¹û·µ»ØÖµ´óÓÚ0£¬Ôò±íʾx´óÓÚy;
Èç¹û·µ»ØֵСÓÚ0£¬Ôò±íʾxСÓÚy;
(2)¿Í»§»¯ÅÅÐòComparetorÓиöcompare(Type x,Type y)·½·¨£¬ÓÃÓڱȽÏÁ½¸ö¶ÔÏóµÄ´óС¡£
µ±compare(x,y)µÄ·µ»ØÖµ´óÓÚ0ʱ£¬±íʾx´óÓÚy;
µ±compare(x,y)µÄ·µ»ØֵСÓÚ0ʱ£¬±íʾxСÓÚy;
µ±compare(x,y)µÄ·µ»ØÖµµÈÓÚ0ʱ£¬±íʾxµÈÓÚy;
Ïà¹ØÎĵµ£º
¹ØÓÚJavaÖи÷ÖÖÐÞÊηûÓë·ÃÎÊÐÞÊηûµÄ˵Ã÷
Àࣺ
·ÃÎÊÐÞÊηû ÐÞÊηû class ÀàÃû³Æ extends ¸¸ÀàÃû³Æ implement ½Ó¿ÚÃû³Æ
£¨·ÃÎÊÐÞÊηûÓëÐÞÊηûµÄλÖÿÉÒÔ»¥»»£©
·ÃÎÊÐÞÊηû
Ãû³Æ
˵Ã÷
±¸×¢
public
¿ÉÒÔ±»ËùÓÐÀà·ÃÎÊ£¨Ê¹Óã©
publicÀà±ØÐ붨ÒåÔÚºÍÀàÃûÏàͬµÄͬÃûÎļþÖÐ
package
¿ÉÒÔ±»Í¬Ò»¸ö°üÖеÄÀà·ÃÎÊ ......
ÎÄÕÂÔ´´£¬×ªÔØÇëÓëBlogÖ÷ÈËÁªÏµ£¬robin9257@hotmail.com
JAVAÓëSQLÇŽӵÄÓÅȱµã£º
1¡¢Óŵ㣺²»ÓÃÏÂÔØÇý¶¯³ÌÐò£¬ÔÊÐíÓÃÏàͬ´úÂë·ÃÎʲ»Í¬DBMS¡£
2¡¢È±µã£ºÐ§Âʵ͡£
¾³£³öÏֵı¨´íµã£º
1¡¢java.sql.SQLException: [Microsoft][ODBC Çý¶¯³ÌÐò¹ÜÀíÆ÷] δ·¢ÏÖÊý¾ÝÔ´Ãû³Æ²¢ÇÒδָ¶¨Ä¬ÈÏÇý¶¯³ÌÐò
&nbs ......
javaģʽ֮µ¥Àýģʽ£º
µ¥Àýģʽȷ±£Ò»¸öÀàÖ»ÓÐÒ»¸öʵÀý£¬×ÔÐÐÌṩÕâ¸öʵÀý²¢ÏòÕû¸öϵͳÌṩÕâ¸öʵÀý¡£
Ìص㣺
1£¬Ò»¸öÀàÖ»ÄÜÓÐÒ»¸öʵÀý
2£¬×Ô¼º´´½¨Õâ¸öʵÀý
& ......
Ò»¡¢Ê²Ã´ÊÇJavaÐéÄâ»ú
JavaÐéÄâ»úÊÇÒ»¸öÏëÏóÖеĻúÆ÷,ÔÚʵ¼ÊµÄ¼ÆËã»úÉÏͨ¹ýÈí¼þÄ£ÄâÀ´ÊµÏÖ¡£JavaÐéÄâ»úÓÐ×Ô¼ºÏëÏóÖеÄÓ²¼þ,Èç´¦ÀíÆ÷¡¢¶ÑÕ»¡¢¼Ä´æÆ÷µÈ,»¹¾ßÓÐÏàÓ¦µÄÖ¸Áîϵͳ¡£
1.ΪʲôҪʹÓÃJavaÐéÄâ»ú
JavaÓïÑÔµÄÒ»¸ö·Ç³£ÖØÒªµÄÌصã¾ÍÊÇÓëƽ̨µÄÎÞ¹ØÐÔ¡£¶øʹÓÃJavaÐéÄâ»úÊÇʵÏÖÕâÒ»ÌصãµÄ¹Ø¼ü¡£Ò»°ãµÄ¸ß¼¶ÓïÑÔÈç¹ ......
oracle
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_S ......