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

javaÊý¾Ý½á¹¹µÄÎÊÌâ - Java / Java SE

·Ö±ð¼¯ºÏÀà¿ò¼ÜÖеÄComparable½Ó¿ÚºÍComparator½Ó¿Ú¼°Ïà¹ØÀ࣬ʵÏÖÔ˶¯Ô±³É¼¨ÐÅÏ¢µÄÅÅÐò¡£ÒªÇó£º
£¨1£©·Ö±ðʵÏÖComparable½Ó¿ÚºÍComparator½Ó¿Ú£¬ÀûÓÃTreeSet¡¢SortedListÀàµÄ¶ÔÏó½øÐÐÅÅÐò£»
£¨2£©ÀûÓÃCollectionsÀàµÄsort·½·¨£¬Ê¹ÓÃVector¡¢ArrayListÀàµÄ¶ÔÏóʵÏÖÅÅÐò


Comparable½Ó¿ÚºÍComparator½Ó¿Ú Á½¸ö¶¼Êǽӿڣ¿ Õâ¸öÌâÄ¿¶¼²»ÖªµÀÔõô×ö£¬ÕâÒ»ÕÅÊý¾Ý½á¹¹£¬¿´ÁË2±éÊéÁË£¬»¹ÊDz»Ôõô¶¯£¬Ë­¸øÏ´𰸰¡¡£

public interface Comparable<T>´Ë½Ó¿ÚÇ¿ÐжÔʵÏÖËüµÄÿ¸öÀàµÄ¶ÔÏó½øÐÐÕûÌåÅÅÐò¡£´ËÅÅÐò±»³ÆΪ¸ÃÀàµÄ×ÔÈ»ÅÅÐò£¬ÀàµÄ compareTo ·½·¨±»³ÆΪËüµÄ×ÔÈ»±È½Ï·½·¨¡£

ʵÏִ˽ӿڵĶÔÏóÁÐ±í£¨ºÍÊý×飩¿ÉÒÔͨ¹ý Collections.sort£¨ºÍ Arrays.sort£©½øÐÐ×Ô¶¯ÅÅÐò¡£ÊµÏִ˽ӿڵĶÔÏó¿ÉÒÔÓÃ×÷ÓÐÐòÓ³Éä±íÖеļü»òÓÐÐò¼¯ºÏÖеÄÔªËØ£¬ÎÞÐèÖ¸¶¨±È½ÏÆ÷¡£

¶ÔÓÚÀà C µÄÿһ¸ö e1 ºÍ e2 À´Ëµ£¬µ±ÇÒ½öµ± (e1.compareTo((Object)e2) == 0) Óë e1.equals((Object)e2) ¾ßÓÐÏàͬµÄ²¼¶ûֵʱ£¬Àà C µÄ×ÔÈ»ÅÅÐò²Å½Ð×öÓë equals Ò»Ö¡£×¢Ò⣬null ²»ÊÇÈκÎÀàµÄʵÀý£¬¼´Ê¹ e.equals(null) ·µ»Ø false£¬e.compareTo(null) Ò²»áÅ׳ö NullPointerException¡£

Ç¿ÁÒÍƼö£¨ËäÈ»²»ÊDZØÐèµÄ£©Ê¹×ÔÈ»ÅÅÐòÓë equals Ò»Ö¡£ÕâÊÇÒòΪÔÚʹÓÃÆä×ÔÈ»ÅÅÐòÓë equals ²»Ò»ÖµÄÔªËØ£¨»ò¼ü£©Ê±£¬Ã»ÓÐÏÔʽ±È½ÏÆ÷µÄÓÐÐò¼¯ºÏ£¨ºÍÓÐÐòÓ³Éä±í£©ÐÐΪ±íÏÖ¡°¹ÖÒ족¡£ÓÈÆäÊÇ£¬ÕâÑùµÄÓÐÐò¼¯ºÏ£¨»òÓÐÐòÓ³Éä±í£©Î¥±³Á˸ù¾Ý equals ·½·¨¶¨ÒåµÄ¼¯ºÏ£¨»òÓ³Éä±í£©µÄ³£¹æЭ¶¨¡£

ÀýÈ磬Èç¹û½«Á½¸ö¼ü a ºÍ b Ìí¼Óµ½Ò»¸öûÓÐʹÓÃÏÔʽ±È½ÏÆ÷µÄÓÐÐò¼¯ºÏÖУ¬Ê¹µÃ (!a.equals((Object)b) && a.compareTo((Object)b) == 0)£¬ÔòµÚ¶þ¸ö add ²Ù×÷·µ»Ø false£¨ÓÐÐò¼¯ºÏµÄ´óСûÓÐÔö¼Ó£©£¬Ò


Ïà¹ØÎÊ´ð£º

JSP/Servlet½»»¥ - Java / Web ¿ª·¢

JSPÒ³ÃæÖÐÓжà¸öradio°´Å¥
  JSPÒ³Ã潫²ÎÊýPOST¸øservlet
  
  ÒªÇóÈçÏÂ;
  1.Ñ¡ÔñÒ»¸öradio£¬µ÷ÓÃservlet servletÖиù¾Ý²ÎÊýµ÷ÓÃÆäËû½Ó¿Ú£¬³ý·ÇÑ¡ÖиÃradio²¢µã»÷JSPÖеÄʵР......

java socket email ÎÊÌâ - Java / Java SE

ÎÒÔÚ javaºËÐļ¼ÊõÉÏ ¿´ÁËÒ»¸ö ÀûÓà Java socket emailµÄÀý×Ó ¿ÉÊÇÔõôҲ ²»³É¹¦ Ϊʲô£¿
Ô´Âë
Java code:

package cn.com.test.email;
import java.awt.GridBagLayout;
import java.awt.event.Action ......

myeclipse+mysqlµÄÅäÖÃÎÊÌâ - Java / Eclipse

ÎÒÊǸöÐÂÊÖ£¬Íû¸ßÊÖ½â´ð
ÎÒÏÖÔÚÒѾ­°²×°ÁËmysql£¬Ò²ÓÐmysqlµÄjdbc¡£µ«ÎÒÔõôÅäÖú󣬲ÅÄÜÔÚMyEclipseÀï²Ù×÷mysqlÄØ£¿Çë¸ßÊÖ˵Ïêϸµã
´ò¿ªMyeclipse----window---open perspective---MyEclipse database explorer-- ......

jspºÍtomcatÎÊÌ⣬¿ì·èÁË - Java / Java EE

ÎÒдÁ˸öjspÒ³Ã棬Ȼºó¸Ä¶¯ÁËһϣ¬¸Ä¶¯µÄÄÚÈݾÍÊÇÔÚjspÒ³ÃæµÄjsº¯ÊýÀï¼ÓÁ˸öalert()Óï¾ä£¬µ«ÊÇÎÒ·ÃÎÊÕâ¸öÒ³Ãæʱ£¬ËÀ»î¶¼ÊÇÔ­À´Ò³ÃæµÄÄÚÈÝ£¬ÎÒ¼ÓÁ˺ܶàalertº¯Êý»¹ÊÇû¸Ä¶¯Ç°µÄÒ³ÃæÄÚÈÝ£»tomcatÖØÆôÁË£¬Ò²ÖØв¿ÊðÕâ ......

java synchronized - Java / Java SE

Java code:

......
synchronized(user){
int loginNum = Integer.parseInt(Main_Client_Dia.jtf2.getText().trim());
Main_Client_Dia.jtf2.setText("");
loginNum++;
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ