锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲中文字幕第一页在线 ,亚洲国产综合人成综合网站00,国产亚洲精品bv在线观看http://www.tkk7.com/yiqi801218/archive/2009/10/19/298883.htmlBlueSunshineBlueSunshineMon, 19 Oct 2009 10:53:00 GMThttp://www.tkk7.com/yiqi801218/archive/2009/10/19/298883.html 銆銆java 鐨勫伐浣滄柟寮忥細1錛岀紪鍐欏嚭婧愪唬鐮侊紝浠?.java 緇撳熬鐨勬枃浠訛紱2錛岀敤緙栬瘧鍣ㄨ繍琛屾簮浠g爜錛屾鏌ラ敊璇紱3錛岀紪璇戝櫒杈撳嚭鐢卞瓧鑺傜爜緇勬垚鐨勬枃浠訛紝浠?.class 緇撳熬鐨勬枃浠躲傜紪璇戝悗鐨勬枃浠朵笌騫沖彴鏃犲叧錛?錛?java 铏氭嫙鏈猴紙JVM錛夎繍琛?.class 鏂囦歡銆?br /> 銆銆JVM鍦ㄦ墽琛屾椂錛屼細閿佸畾 main() 鏂規硶銆傚洜姝ゆ瘡涓簲鐢ㄧ▼搴忔湁涓斿彧鏈変竴涓?main() 鏂規硶銆傚綋鐒訛紝姣忎釜紼嬪簭閲屽彲浠ユ湁涓涓垨澶氫釜綾伙紝鎵浠ユ湁鐨勭被閲岄潰鏄病鏈?main() 鏂規硶鐨勩?br />

BlueSunshine 2009-10-19 18:53 鍙戣〃璇勮
]]>
媧誨姩澶ц剳http://www.tkk7.com/yiqi801218/archive/2008/08/15/222148.htmlBlueSunshineBlueSunshineFri, 15 Aug 2008 01:27:00 GMThttp://www.tkk7.com/yiqi801218/archive/2008/08/15/222148.htmlhttp://www.tkk7.com/yiqi801218/comments/222148.htmlhttp://www.tkk7.com/yiqi801218/archive/2008/08/15/222148.html#Feedback0http://www.tkk7.com/yiqi801218/comments/commentRss/222148.htmlhttp://www.tkk7.com/yiqi801218/services/trackbacks/222148.html1銆棰樼洰濡備笅錛氾紙 http://www.javaeye.com/topic/226364?page=1錛?br /> 緇欎綘10鍒嗛挓鏃墮棿錛屾牴鎹笂鎺掔粰鍑哄崄涓暟錛屽湪鍏朵笅鎺掑~鍑哄搴旂殑鍗佷釜鏁?
瑕佹眰涓嬫帓姣忎釜鏁伴兘鏄厛鍓嶄笂鎺掗偅鍗佷釜鏁板湪涓嬫帓鍑虹幇鐨勬鏁般?
涓婃帓鐨勫崄涓暟濡備笅錛?
銆?錛?錛?錛?錛?錛?錛?錛?錛?錛?銆?

灝忔彁紺猴細涓嬫帓鐨?0涓暟涔嬪拰姝eソ鏄?0

絳旀錛?br /> ##########銆?銆?#########
##########銆?銆?#########
##########銆?銆?#########
##########銆?銆?#########
鏁板?0,1,2,3
鍒嗛厤:1,2,1,0
鏁板?0,1,2,3
鍒嗛厤:2,0,2,0
##########銆?銆?#########
鏁板?0,1,2,3,4
鍒嗛厤:2,1,2,0,0
##########銆?銆?#########
##########銆?銆?#########
鏁板?0,1,2,3,4,5,6
鍒嗛厤:3,2,1,1,0,0,0
##########銆?銆?#########
鏁板?0,1,2,3,4,5,6,7
鍒嗛厤:4,2,1,0,1,0,0,0
##########銆?銆?#########
鏁板?0,1,2,3,4,5,6,7,8
鍒嗛厤:5,2,1,0,0,1,0,0,0
##########銆?0銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9
鍒嗛厤:6,2,1,0,0,0,1,0,0,0
##########銆?1銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10
鍒嗛厤:7,2,1,0,0,0,0,1,0,0,0
##########銆?2銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11
鍒嗛厤:8,2,1,0,0,0,0,0,1,0,0,0
##########銆?3銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12
鍒嗛厤:9,2,1,0,0,0,0,0,0,1,0,0,0
##########銆?4銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12,13
鍒嗛厤:10,2,1,0,0,0,0,0,0,0,1,0,0,0
##########銆?5銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
鍒嗛厤:11,2,1,0,0,0,0,0,0,0,0,1,0,0,0
##########銆?6銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
鍒嗛厤:12,2,1,0,0,0,0,0,0,0,0,0,1,0,0,0
##########銆?7銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
鍒嗛厤:13,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0
##########銆?8銆?#########
鏁板?0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
鍒嗛厤:14,2,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0

鍙槸涓嶇煡閬撴槸鍚﹀敮涓錛?/p>

2銆鏈夊崄浜屼釜涔掍箵鐞冪壒寰佺浉鍚岋紝鍏朵腑鍙湁涓涓噸閲?strong>寮傚父錛岀幇鍦ㄨ姹傜敤涓閮ㄦ病鏈夌牆鐮佺殑澶╁鉤縐頒笁嬈★紝灝嗛偅涓噸閲忓紓甯哥殑鐞冩壘鍑烘潵銆?/p> 銆
絳旀錛氥涓涓緢閰風殑JS鍐欑殑瑙f硶銆http://www.blueidea.com/bbs/NewsDetail.asp?id=523379

 1 鍦?2涓皬鐞冧腑鏈変竴涓拰鍏朵粬涓嶅悓錛堟垨杞繪垨閲嶏級,鐜板湪鍏堟嬁璧風瑪,璁頒笅鍝釜鐞冮噸鎴栬呰交錛岀劧鍚庣戶緇笅闈㈢殑娓告垙<br><br><br>
 2 <select name=one></select>
 3 <select name=two></select>
 4 <select name=three></select>
 5 <select name=four></select>
 6 
 7 <script>
 8 var arrSel=["one","two","three","four"];//arrSel瀹氫箟浜嗚淇敼鐨勪笅鎷夋
 9 var i=0,arrData=[];//arrData涓悂鐨勬槸鏁版嵁,姣忔潯閮芥樉紺哄悇綰х殑鏁版嵁
10 arrData[i++]=["(1,2,3,4)姣?5,6,7,8)","璇峰厛鍋氬墠闈㈢殑閫夋嫨","璇峰厛鍋氬墠闈㈢殑閫夋嫨","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
11 arrData[i++]=["閲?/span>","(1,2,5)姣?3,6,9)","璇峰厛鍋氬墠闈㈢殑閫夋嫨","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
12 arrData[i++]=["閲?/span>","閲?/span>","(1)姣?2)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
13 arrData[i++]=["閲?/span>","閲?/span>","閲?/span>","1鐞冩瘮杈冮噸"]
14 arrData[i++]=["閲?/span>","閲?/span>","騫?/span>","6鐞冩瘮杈冭交"]
15 arrData[i++]=["閲?/span>","閲?/span>","杞?/span>","2鐞冩瘮杈冮噸"]
16 arrData[i++]=["閲?/span>","騫?/span>","(7)姣?8)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
17 arrData[i++]=["閲?/span>","騫?/span>","閲?/span>","8鐞冩瘮杈冭交"]
18 arrData[i++]=["閲?/span>","騫?/span>","騫?/span>","4鐞冩瘮杈冮噸"]
19 arrData[i++]=["閲?/span>","騫?/span>","杞?/span>","7鐞冩瘮杈冭交"]
20 arrData[i++]=["閲?/span>","杞?/span>","(1)姣?3)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
21 arrData[i++]=["閲?/span>","杞?/span>","閲?/span>","鏃犺В"]
22 arrData[i++]=["閲?/span>","杞?/span>","騫?/span>","5鐞冩瘮杈冭交"]
23 arrData[i++]=["閲?/span>","杞?/span>","杞?/span>","3鐞冩瘮杈冮噸"]
24 arrData[i++]=["騫?/span>","(9,10)姣?1,11)","璇峰厛鍋氬墠闈㈢殑閫夋嫨","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
25 arrData[i++]=["騫?/span>","閲?/span>","(9)姣?11)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
26 arrData[i++]=["騫?/span>","閲?/span>","閲?/span>","9鐞冩瘮杈冮噸"]
27 arrData[i++]=["騫?/span>","閲?/span>","騫?/span>","11鐞冩瘮杈冭交"]
28 arrData[i++]=["騫?/span>","閲?/span>","杞?/span>","10鐞冩瘮杈冮噸"]
29 arrData[i++]=["騫?/span>","騫?/span>","(1)姣?12)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
30 arrData[i++]=["騫?/span>","騫?/span>","閲?/span>","12鐞冩瘮杈冭交"]
31 arrData[i++]=["騫?/span>","騫?/span>","騫?/span>","鏃犺В"]
32 arrData[i++]=["騫?/span>","騫?/span>","杞?/span>","12鐞冩瘮杈冮噸"]
33 arrData[i++]=["騫?/span>","杞?/span>","(9)姣?10)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
34 arrData[i++]=["騫?/span>","杞?/span>","閲?/span>","9鐞冩瘮杈冭交"]
35 arrData[i++]=["騫?/span>","杞?/span>","騫?/span>","11鐞冩瘮杈冮噸"]
36 arrData[i++]=["騫?/span>","杞?/span>","杞?/span>","10鐞冩瘮杈冭交"]
37 arrData[i++]=["杞?/span>","(1,2,5)姣?3,6,9)","璇峰厛鍋氬墠闈㈢殑閫夋嫨","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
38 arrData[i++]=["杞?/span>","閲?/span>","(1)姣?3)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
39 arrData[i++]=["杞?/span>","閲?/span>","閲?/span>","3鐞冩瘮杈冭交"]
40 arrData[i++]=["杞?/span>","閲?/span>","騫?/span>","5鐞冩瘮杈冮噸"]
41 arrData[i++]=["杞?/span>","閲?/span>","杞?/span>","鏃犺В"]
42 arrData[i++]=["杞?/span>","騫?/span>","(7)姣?8)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
43 arrData[i++]=["杞?/span>","騫?/span>","閲?/span>","7鐞冩瘮杈冮噸"]
44 arrData[i++]=["杞?/span>","騫?/span>","騫?/span>","4鐞冩瘮杈冭交"]
45 arrData[i++]=["杞?/span>","騫?/span>","杞?/span>","8鐞冩瘮杈冮噸"]
46 arrData[i++]=["杞?/span>","杞?/span>","(1)姣?2)","璇峰厛鍋氬墠闈㈢殑閫夋嫨"]
47 arrData[i++]=["杞?/span>","杞?/span>","閲?/span>","2鐞冩瘮杈冭交"]
48 arrData[i++]=["杞?/span>","杞?/span>","騫?/span>","6鐞冩瘮杈冮噸"]
49 arrData[i++]=["杞?/span>","杞?/span>","杞?/span>","1鐞冩瘮杈冭交"]
50 </script>
51 <script>
52 function qswhInit(num){
53 /******* by qiushuiwuhen(2002-5-15) ********/
54     var i,j,arrTemp=[];
55     for(i=0;i<num;i++)arrTemp[i]=document.all(arrSel[i]).options[document.all(arrSel[i]).selectedIndex].text
56     if(num==arrSel.length){//榪欓噷澶勭悊鏈鍚庣殑鏁版嵁銆?/span>
57         return;
58     }
59     with(document.all(arrSel[num])){
60         length=0
61         for(i=0;i<arrData.length;i++){        
62             for(j=0;j<num;j++)if(arrTemp[j]!=arrData[i][j])break;
63             if(j!=num)continue;
64             if(length==0||options[length-1].text!=arrData[i][num])
65             options[length++].text=arrData[i][num];
66         }
67         onchange=new Function("qswhInit("+(num+1)+")");
68         onchange();
69     }
70 }
71 qswhInit(0);//鍒濆鍖?/span>
72 </script>
73 


BlueSunshine 2008-08-15 09:27 鍙戣〃璇勮
]]>
鐢熸垚 Excel鏂囦歡http://www.tkk7.com/yiqi801218/archive/2008/08/04/220047.htmlBlueSunshineBlueSunshineMon, 04 Aug 2008 14:15:00 GMThttp://www.tkk7.com/yiqi801218/archive/2008/08/04/220047.htmlhttp://www.tkk7.com/yiqi801218/comments/220047.htmlhttp://www.tkk7.com/yiqi801218/archive/2008/08/04/220047.html#Feedback1http://www.tkk7.com/yiqi801218/comments/commentRss/220047.htmlhttp://www.tkk7.com/yiqi801218/services/trackbacks/220047.html鍖呬笅杞藉湴鍧錛?a href="http://www.apache.org/dist/jakarta/poi/release/bin/ xxx .zip">http://www.apache.org/dist/jakarta/poi/release/bin/ xxx .zip

鍙傝冿細http://www.oracle.com/technology/global/cn/pub/articles/saternos_tables.html浣跨敤 Apache Jakarta POI 浠?Excel 鐢靛瓙琛ㄦ牸鐢熸垚澶栭儴琛?br /> 銆銆銆http://blog.tostudy.com.cn/blog/show_996.html
銆銆銆http://blog.tostudy.com.cn/blog/show_995.html

涓銆鍒涘緩Excel 鏂囨。

銆銆紺轟緥1灝嗘紨紺哄浣曞埄鐢↗akarta POI API 鍒涘緩Excel 鏂囨。銆?br />
銆銆紺轟緥1紼嬪簭濡備笅錛?br />

 1 package all;
 2 
 3 import java.io.FileOutputStream;
 4 
 5 import org.apache.poi.hssf.usermodel.HSSFCell;
 6 import org.apache.poi.hssf.usermodel.HSSFRow;
 7 import org.apache.poi.hssf.usermodel.HSSFSheet;
 8 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 9 
10 public class CreateXL {
11 
12     /** Excel 鏂囦歡瑕佸瓨鏀劇殑浣嶇疆錛屽亣瀹氬湪D鐩樹笅 */
13 
14     public static String outputFile = "D:\\english.xls";
15 
16     public static void main(String argv[]) {
17 
18         try {
19 
20             // 鍒涘緩鏂扮殑Excel 宸ヤ綔綈?/span>
21 
22             HSSFWorkbook workbook = new HSSFWorkbook();
23 
24             // 鍦‥xcel宸ヤ綔綈夸腑寤轟竴宸ヤ綔琛紝鍏跺悕涓虹己鐪佸?br /> 25             // 濡傝鏂板緩涓鍚嶄負"鏁堢泭鎸囨爣"鐨勫伐浣滆〃錛屽叾璇彞涓猴細
26             // HSSFSheet sheet = workbook.createSheet("鏁堢泭鎸囨爣");
27             HSSFSheet sheet = workbook.createSheet("EnglishTable");
28 
29             // 鍦ㄧ儲寮?鐨勪綅緗垱寤鴻錛堟渶欏剁鐨勮錛?/span>
30 
31             HSSFRow row = sheet.createRow((short0);
32 
33             // 鍦ㄧ儲寮?鐨勪綅緗垱寤哄崟鍏冩牸錛堝乏涓婄錛?/span>
34             HSSFCell cell = row.createCell((short0);
35             // 瀹氫箟鍗曞厓鏍間負瀛楃涓茬被鍨?/span>
36             cell.setCellType(HSSFCell.CELL_TYPE_STRING);
37             // 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹?/span>
38             cell.setCellValue("澧炲姞鍊?/span>");
39             // 鏂板緩涓杈撳嚭鏂囦歡嫻?/span>
40             FileOutputStream fOut = new FileOutputStream(outputFile);
41             // 鎶婄浉搴旂殑Excel 宸ヤ綔綈垮瓨鐩?/span>
42             workbook.write(fOut);
43             fOut.flush();
44             // 鎿嶄綔緇撴潫錛屽叧闂枃浠?/span>
45             fOut.close();
46             System.out.println("鏂囦歡鐢熸垚");
47 
48         } catch (Exception e) {
49             System.out.println("宸茶繍琛?nbsp;xlCreate() : " + e);
50         }
51     }
52 }
53 

銆銆

浜屻璇誨彇Excel鏂囨。涓殑鏁版嵁

銆銆紺轟緥2灝嗘紨紺哄浣曡鍙朎xcel鏂囨。涓殑鏁版嵁銆傚亣瀹氬湪D鐩楯Test鐩綍涓嬫湁涓涓枃浠跺悕涓簍est1.xls鐨凟xcel鏂囦歡銆?br />
銆銆紺轟緥2紼嬪簭濡備笅錛?br />

 

 1 package all;
 2 
 3 import java.io.FileInputStream;
 4 
 5 import org.apache.poi.hssf.usermodel.HSSFCell;
 6 import org.apache.poi.hssf.usermodel.HSSFRow;
 7 import org.apache.poi.hssf.usermodel.HSSFSheet;
 8 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 9 
10 public class ReadXL {
11     /**
12      * Excel鏂囦歡鐨勫瓨鏀句綅緗細娉ㄦ剰鏄袱涓弽鏂滅嚎銆?nbsp;鎴栬呭彲浠ョ敤涓涓鏂滅嚎 D:/test.xls
13      * */
14     public static String fileToBeRead = "D:\\test.xls";
15 
16     public static void main(String argv[]) {
17         try {
18             // 鍒涘緩瀵笶xcel宸ヤ綔綈挎枃浠剁殑寮曠敤
19             HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(fileToBeRead));
20             // 鍒涘緩瀵瑰伐浣滆〃鐨勫紩鐢ㄣ?br /> 21             // 鏈緥鏄寜鍚嶅紩鐢紙璁╂垜浠亣瀹氶偅寮犺〃鏈夌潃緙虹渷鍚?Sheet1"錛?/span>
22             HSSFSheet sheet = workbook.getSheet("Sheet");
23             // 涔熷彲鐢╣etSheetAt(int index)鎸夌儲寮曞紩鐢紝
24             // 鍦‥xcel鏂囨。涓紝絎竴寮犲伐浣滆〃鐨勭己鐪佺儲寮曟槸0錛?br /> 25             // 鍏惰鍙ヤ負錛欻SSFSheet sheet = workbook.getSheetAt(0);
26             // 璇誨彇宸︿笂绔崟鍏?/span>
27             HSSFRow row = sheet.getRow(0);
28             HSSFCell cell = row.getCell((short0);
29             // 杈撳嚭鍗曞厓鍐呭錛宑ell.getStringCellValue()灝辨槸鍙栨墍鍦ㄥ崟鍏冪殑鍊?/span>
30             System.out.println("宸︿笂绔崟鍏冩槸錛?nbsp;" + cell.getStringCellValue());
31         } catch (Exception e) {
32             System.out.println("宸茶繍琛寈lRead() : " + e);
33             e.printStackTrace();
34         }
35     }
36 }
37 



涓夈璁劇疆鍗曞厓鏍兼牸寮?br />
銆銆鍦ㄨ繖閲岋紝鎴戜滑灝嗗彧浠嬬粛涓浜涘拰鏍煎紡璁劇疆鏈夊叧鐨勮鍙ワ紝鎴戜滑鍋囧畾workbook灝辨槸瀵逛竴涓伐浣滅翱鐨勫紩鐢ㄣ傚湪Java涓紝絎竴姝ヨ鍋氱殑灝辨槸鍒涘緩鍜岃緗瓧浣撳拰鍗曞厓鏍肩殑鏍煎紡錛岀劧鍚庡啀搴旂敤榪欎簺鏍煎紡錛?br />
銆銆1銆佸垱寤哄瓧浣擄紝璁劇疆鍏朵負綰㈣壊銆佺矖浣撱佸瓧鍙峰ぇ灝忎負18

HSSFFont font = workbook.createFont();
font.setColor(HSSFFont.COLOR_RED);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 18);

銆銆2銆佸垱寤烘牸寮?br />
HSSFCellStyle cellStyle= workbook.createCellStyle();
cellStyle.setFont(font);

銆銆3銆佸簲鐢ㄦ牸寮?br />
HSSFCell cell = row.createCell((short) 0);
cell.setCellStyle(cellStyle);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("鏍囬 ");銆


鍥涖澶勭悊WORD鏂囨。錛堣繕娌″紕鏄庣櫧鍏充簬word鏂囨。錛屾湁寰呭涔狅級

import java.io.*;
import org.textmining.text.extraction.WordExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;

public class TestPoi {
public TestPoi() {
}
public static void main(String args[]) throws Exception
{
FileInputStream in = new FileInputStream ("D:\\a.doc");
WordExtractor extractor = new WordExtractor();
String str = extractor.extractText(in);
//System.out.println("the result length is"+str.length());
System.out.println(str);
}
}
鍚慐XCEL鏂囦歡涓鍏ユ暟鎹互鍙婅鍙朎xcel鏂囨。涓殑鏁版嵁銆?/p>

BlueSunshine 2008-08-04 22:15 鍙戣〃璇勮
]]>
瀛︿範闆嗗悎涓庢硾鍨?/title><link>http://www.tkk7.com/yiqi801218/archive/2008/07/09/213484.html</link><dc:creator>BlueSunshine</dc:creator><author>BlueSunshine</author><pubDate>Tue, 08 Jul 2008 18:47:00 GMT</pubDate><guid>http://www.tkk7.com/yiqi801218/archive/2008/07/09/213484.html</guid><wfw:comment>http://www.tkk7.com/yiqi801218/comments/213484.html</wfw:comment><comments>http://www.tkk7.com/yiqi801218/archive/2008/07/09/213484.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.tkk7.com/yiqi801218/comments/commentRss/213484.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/yiqi801218/services/trackbacks/213484.html</trackback:ping><description><![CDATA[涓銆鎴戞墍鐭ラ亾鐨勯泦鍚堛<br /> <br /> 銆銆鎴戠煡閬撶殑絎竴涓泦鍚堬細ArrayList錛屽姞鍏ュ厓绱犻潪甯告柟渚匡紝add(Object elem)銆傚叾瀹冪殑錛?TreeSet錛堟湁搴忓茍闃叉閲嶅錛? HashMap錛堝悕鍊煎錛? LinkedList錛堜負緇忓父鎻掑叆鎴栧垹闄や腑闂村厓绱犳墍璁捐鐨勯珮鏁堥泦鍚堬級, HashSet錛堥槻姝㈤噸澶嶏紝鍙揩閫熸壘瀵葷鍚堢殑鍏冪礌錛? LinkedHashMap錛堢被鍨嬩簬HashMap, 浣嗗彲浠ヨ浣忓厓绱犳彃鍏ョ殑欏哄簭錛屼篃鍙互璁懼畾鎴愪緷鐓у厓绱犱笂嬈″瓨鍙栫殑鍏堝悗鏉ユ帓搴忥級銆傛葷殑鏉ヨ錛岃繖浜涢泦鍚堝彲浠ョ敤“欏哄簭”鍜?#8220;閲嶅”鏉ュ尯鍒嗐?br /> <br /> 銆銆涓嬮潰涓ゅ浘鐢ㄦ潵璇存槑3涓富瑕佺殑鎺ュ彛錛歀ist, Set 鍜?Map.錛堥儴鍒嗭級<br /> <img height="720" alt="" src="http://www.tkk7.com/images/blogjava_net/yiqi801218/1.JPG" width="960" border="0" /><br /> <br /> <img style="width: 953px; height: 715px" height="715" alt="" src="http://www.tkk7.com/images/blogjava_net/yiqi801218/2.JPG" width="953" border="0" /><br /> 浜屻欏哄簭<br /> <br /> 銆銆欏哄簭闂錛屽彲浠ョ敤TreeSet鎴朇ollections.sort()鏉ュ疄鐜般傚綋鎻掑叆鏂板厓绱犳椂錛孴reeSet浼氳姳鏃墮棿鎵懼埌閫傚綋鐨勪綅緗紝鎵浠ョ浉瀵硅鎱簡銆傝孉rrayList鍙鎶婃柊鍔犵殑鍏冪礌鏀懼埌鏈鍚庡氨濂姐傦紙褰撶劧錛孉rrayList涔熸湁閲嶈澆鐨刟dd(index, element )鍙互鎻掑埌鎸囧畾浣嶇疆錛屼篃鎱紝閫氬父涓嶈繖鏍峰仛銆傦級<br /> 銆銆sort(List<T> list) 鏂規硶 /* public static <T extends Comparable<? super T>> void sort(List<T> list) */ 錛氬彧浼犲叆Comparable 鎺ュ彛鐨?list 浣滀負鍙傛暟銆侰omparable鏈変竴涓柟娉曡瀹炵幇錛歝ompareTo(T o)鏂規硶銆?br /> 銆銆鎴栬呯敤閲嶈澆鐨剆ort()鏂規硶錛歴ort(List<T> list, Comparator< ? super T> c)鏂規硶銆銆傝繖鏍鳳紝灝辯敤涓嶇潃compareTo()鏂規硶浜嗐傝屾槸瑕佸疄鐜癈omparator鎺ュ彛錛屽疄鐜癱ompare()鏂規硶銆?br />  <br /> 瀹炰緥1錛嶅叧浜?sort(List<T> list)<br /> <br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img id="Codehighlighter1_0_26_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_26_Open_Text.style.display='none'; Codehighlighter1_0_26_Closed_Image.style.display='inline'; Codehighlighter1_0_26_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_0_26_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_0_26_Closed_Text.style.display='none'; Codehighlighter1_0_26_Open_Image.style.display='inline'; Codehighlighter1_0_26_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span id="Codehighlighter1_0_26_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_0_26_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000"> Class StudyComparable </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">package</span><span style="color: #000000"> conllection;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Collections;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.LinkedList;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_139_570_Open_Image" onclick="this.style.display='none'; Codehighlighter1_139_570_Open_Text.style.display='none'; Codehighlighter1_139_570_Closed_Image.style.display='inline'; Codehighlighter1_139_570_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_139_570_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_139_570_Closed_Text.style.display='none'; Codehighlighter1_139_570_Open_Image.style.display='inline'; Codehighlighter1_139_570_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> StudyComparable </span><span id="Codehighlighter1_139_570_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_139_570_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    LinkedList</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000"> psn </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> LinkedList</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000">();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_234_294_Open_Image" onclick="this.style.display='none'; Codehighlighter1_234_294_Open_Text.style.display='none'; Codehighlighter1_234_294_Closed_Image.style.display='inline'; Codehighlighter1_234_294_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_234_294_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_234_294_Closed_Text.style.display='none'; Codehighlighter1_234_294_Open_Image.style.display='inline'; Codehighlighter1_234_294_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> main(String[] args) </span><span id="Codehighlighter1_234_294_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_234_294_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        StudyComparable sc </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StudyComparable();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        sc.go();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_316_568_Open_Image" onclick="this.style.display='none'; Codehighlighter1_316_568_Open_Text.style.display='none'; Codehighlighter1_316_568_Closed_Image.style.display='inline'; Codehighlighter1_316_568_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_316_568_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_316_568_Closed_Text.style.display='none'; Codehighlighter1_316_568_Open_Image.style.display='inline'; Codehighlighter1_316_568_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> go() </span><span id="Codehighlighter1_316_568_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_316_568_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">one</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">3</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">two</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">2</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">three</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">5</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">five</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">6</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">eight</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">8</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        Collections.sort(psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_574_591_Open_Image" onclick="this.style.display='none'; Codehighlighter1_574_591_Open_Text.style.display='none'; Codehighlighter1_574_591_Closed_Image.style.display='inline'; Codehighlighter1_574_591_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_574_591_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_574_591_Closed_Text.style.display='none'; Codehighlighter1_574_591_Open_Image.style.display='inline'; Codehighlighter1_574_591_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_574_591_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_574_591_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000"> Class Person </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">package</span><span style="color: #000000"> conllection;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_666_905_Open_Image" onclick="this.style.display='none'; Codehighlighter1_666_905_Open_Text.style.display='none'; Codehighlighter1_666_905_Closed_Image.style.display='inline'; Codehighlighter1_666_905_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_666_905_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_666_905_Closed_Text.style.display='none'; Codehighlighter1_666_905_Open_Image.style.display='inline'; Codehighlighter1_666_905_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> Person </span><span style="color: #0000ff">implements</span><span style="color: #000000"> Comparable</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000"> </span><span id="Codehighlighter1_666_905_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_666_905_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    String name;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="color: #0000ff">int</span><span style="color: #000000"> age;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_725_751_Open_Image" onclick="this.style.display='none'; Codehighlighter1_725_751_Open_Text.style.display='none'; Codehighlighter1_725_751_Closed_Image.style.display='inline'; Codehighlighter1_725_751_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_725_751_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_725_751_Closed_Text.style.display='none'; Codehighlighter1_725_751_Open_Image.style.display='inline'; Codehighlighter1_725_751_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> Person(String n, </span><span style="color: #0000ff">int</span><span style="color: #000000"> a) </span><span id="Codehighlighter1_725_751_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_725_751_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        name </span><span style="color: #000000">=</span><span style="color: #000000"> n;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        age </span><span style="color: #000000">=</span><span style="color: #000000"> a;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    @Override<br /> <img id="Codehighlighter1_797_833_Open_Image" onclick="this.style.display='none'; Codehighlighter1_797_833_Open_Text.style.display='none'; Codehighlighter1_797_833_Closed_Image.style.display='inline'; Codehighlighter1_797_833_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_797_833_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_797_833_Closed_Text.style.display='none'; Codehighlighter1_797_833_Open_Image.style.display='inline'; Codehighlighter1_797_833_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> compareTo(Person o) </span><span id="Codehighlighter1_797_833_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_797_833_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> name.compareTo(o.name);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    @Override<br /> <img id="Codehighlighter1_873_903_Open_Image" onclick="this.style.display='none'; Codehighlighter1_873_903_Open_Text.style.display='none'; Codehighlighter1_873_903_Closed_Image.style.display='inline'; Codehighlighter1_873_903_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_873_903_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_873_903_Closed_Text.style.display='none'; Codehighlighter1_873_903_Open_Image.style.display='inline'; Codehighlighter1_873_903_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String toString() </span><span id="Codehighlighter1_873_903_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_873_903_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> name </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">/</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> age;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <br /> 榪愯緇撴灉錛?br /> 銆銆[one/3, two/2, three/5, five/6, eight/8]<br />         [eight/8, five/6, one/3, three/5, two/2]<br /> <br /> 銆銆鐜板湪錛屽彲浠ユ寜鐓ame鏉ユ帓搴忎簡錛屼笉榪囨垜鎯崇敤age 鏉ユ帓搴忥紝灝辮鏀逛唬鐮侊紝鐢≒erson綾諱腑鐨刢ompareTo()鏂規硶榪涘叆age鐨勬瘮杈冦傝繖鏍峰仛寰堜笉濂斤紝鎵浠ュ彲浠ョ敤閲嶈澆鐨剆ort(List<T> list, Comparator<? super T> c)鏂規硶銆?br /> <br /> 瀹炰緥2錛嶅叧浜?sort(List <T> list, Comparator <? super T> c)<br /> <br /> Class StudyComparator<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> conllection;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.ArrayList;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Collections;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Comparator;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_139_1044_Open_Image" onclick="this.style.display='none'; Codehighlighter1_139_1044_Open_Text.style.display='none'; Codehighlighter1_139_1044_Closed_Image.style.display='inline'; Codehighlighter1_139_1044_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_139_1044_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_139_1044_Closed_Text.style.display='none'; Codehighlighter1_139_1044_Open_Image.style.display='inline'; Codehighlighter1_139_1044_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> StudyComparator </span><span id="Codehighlighter1_139_1044_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_139_1044_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />    ArrayList</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000"> psn </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> ArrayList</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000">();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_232_292_Open_Image" onclick="this.style.display='none'; Codehighlighter1_232_292_Open_Text.style.display='none'; Codehighlighter1_232_292_Closed_Image.style.display='inline'; Codehighlighter1_232_292_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_232_292_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_232_292_Closed_Text.style.display='none'; Codehighlighter1_232_292_Open_Image.style.display='inline'; Codehighlighter1_232_292_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> main(String[] args) </span><span id="Codehighlighter1_232_292_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_232_292_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        StudyComparator sc </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StudyComparator();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        sc.go();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_347_451_Open_Image" onclick="this.style.display='none'; Codehighlighter1_347_451_Open_Text.style.display='none'; Codehighlighter1_347_451_Closed_Image.style.display='inline'; Codehighlighter1_347_451_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_347_451_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_347_451_Closed_Text.style.display='none'; Codehighlighter1_347_451_Open_Image.style.display='inline'; Codehighlighter1_347_451_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">class</span><span style="color: #000000"> NameComparator </span><span style="color: #0000ff">implements</span><span style="color: #000000"> Comparator</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000"> </span><span id="Codehighlighter1_347_451_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_347_451_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        @Override<br /> <img id="Codehighlighter1_405_447_Open_Image" onclick="this.style.display='none'; Codehighlighter1_405_447_Open_Text.style.display='none'; Codehighlighter1_405_447_Closed_Image.style.display='inline'; Codehighlighter1_405_447_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_405_447_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_405_447_Closed_Text.style.display='none'; Codehighlighter1_405_447_Open_Image.style.display='inline'; Codehighlighter1_405_447_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> compare(Person o1, Person o2) </span><span id="Codehighlighter1_405_447_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_405_447_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="color: #0000ff">return</span><span style="color: #000000"> o1.name.compareTo(o2.name);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_505_598_Open_Image" onclick="this.style.display='none'; Codehighlighter1_505_598_Open_Text.style.display='none'; Codehighlighter1_505_598_Closed_Image.style.display='inline'; Codehighlighter1_505_598_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_505_598_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_505_598_Closed_Text.style.display='none'; Codehighlighter1_505_598_Open_Image.style.display='inline'; Codehighlighter1_505_598_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">class</span><span style="color: #000000"> AgeComparator </span><span style="color: #0000ff">implements</span><span style="color: #000000"> Comparator</span><span style="color: #000000"><</span><span style="color: #000000">Person</span><span style="color: #000000">></span><span style="color: #000000"> </span><span id="Codehighlighter1_505_598_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_505_598_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        @Override<br /> <img id="Codehighlighter1_563_594_Open_Image" onclick="this.style.display='none'; Codehighlighter1_563_594_Open_Text.style.display='none'; Codehighlighter1_563_594_Closed_Image.style.display='inline'; Codehighlighter1_563_594_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_563_594_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_563_594_Closed_Text.style.display='none'; Codehighlighter1_563_594_Open_Image.style.display='inline'; Codehighlighter1_563_594_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> compare(Person o1, Person o2) </span><span id="Codehighlighter1_563_594_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_563_594_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="color: #0000ff">return</span><span style="color: #000000"> o1.age </span><span style="color: #000000">-</span><span style="color: #000000"> o2.age;<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img id="Codehighlighter1_620_1042_Open_Image" onclick="this.style.display='none'; Codehighlighter1_620_1042_Open_Text.style.display='none'; Codehighlighter1_620_1042_Closed_Image.style.display='inline'; Codehighlighter1_620_1042_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_620_1042_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_620_1042_Closed_Text.style.display='none'; Codehighlighter1_620_1042_Open_Image.style.display='inline'; Codehighlighter1_620_1042_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> go() </span><span id="Codehighlighter1_620_1042_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_620_1042_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">one</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">3</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">two</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">2</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">three</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">5</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">five</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">6</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        psn.add(</span><span style="color: #0000ff">new</span><span style="color: #000000"> Person(</span><span style="color: #000000">"</span><span style="color: #000000">eight</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">8</span><span style="color: #000000">));<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        NameComparator nc </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> NameComparator();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        Collections.sort(psn, nc);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(</span><span style="color: #000000">"</span><span style="color: #000000">onName:</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        AgeComparator ac </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> AgeComparator();<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        Collections.sort(psn, ac);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(</span><span style="color: #000000">"</span><span style="color: #000000">onAge:</span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> psn);<br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <br /> 銆銆Class Person:鍚屼緥1涓殑Person.Class 銆傚洜涓哄湪StudyComparator閲岄潰瀹氫箟浜咰omparator鐨勫疄鐜扮被錛屾墍浠erson綾諱笉鐢ㄥ姩錛屼篃灝辨槸璇達紝鍦ㄦ病鏈夊師浠g爜鐨勬儏鍐典笅涔熷疄鐜頒簡sort錛岃屼笖鍙寜涓嶅悓鐨勫睘鎬ф潵榪涜鎺掑簭錛屾垜鏇村枩嬈㈣繖涓噸杞界殑sort()鏂規硶銆?br /> <br /> 榪愯緇撴灉錛?br /> <br /> [one/3, two/2, three/5, five/6, eight/8]<br /> onName:[eight/8, five/6, one/3, three/5, two/2]<br /> onAge:[two/2, one/3, three/5, five/6, eight/8]<br /> <br /> <br /> 涓夈閲嶅<br /> <br /> 銆銆1銆鐩哥瓑銆錛濓紳<br /> <br /> 銆銆闃叉閲嶅錛岀敤Set銆傝瑙e喅鐨勭涓涓棶棰橈細涓や釜瀵硅薄鐨勫紩鐢ㄦ庢牱鎵嶇畻鏄噸澶嶏紵絳旀灝辨槸瀹冧滑鏄浉絳夌殑銆傞偅涔堟庢牱綆?#8216;鐩哥瓑’錛熸樉鐒朵笉鏄崟綰殑鍊肩浉絳夈?#8216;鐩哥瓑’鍖呮嫭寮曠敤鐩哥瓑鍜屽璞$浉絳夈?br /> 銆銆<strong>寮曠敤鐩哥瓑</strong>錛氬紩鐢ㄥ爢涓婄殑鍚屼竴瀵硅薄鐨勪袱涓紩鐢ㄦ槸鐩哥瓑鐨勩傚鏋滃涓や釜寮曠敤璋冪敤hashCode() 錛屼細寰楀埌鐩稿悓鐨勭粨鏋溿俬ashCode()錛堥粯璁ょ殑琛屼負錛変細榪斿洖瀵硅薄鍦ㄥ爢涓婄殑鐗規湁鐨勫敮涓搴忓彿銆傛樉鐒訛紝涓嶅悓瀵硅薄鐨勫紩鐢ㄧ殑hashCode()鐨勫兼槸涓嶅悓鐨勩?br /> 銆銆<strong>瀵硅薄鐩哥瓑</strong>錛氬爢涓婄殑涓や釜涓嶅悓瀵硅薄錛屽湪鎰忎箟涓婄浉鍚屻?br /> 銆銆鍥犳錛?strong><span style="color: red"><strong>鎯寵涓や釜涓嶅悓鐨勫璞?#8216;鐩哥瓑’錛屽氨蹇呴』瑕乷verride hashCode()鍜宔quals()鏂規硶</strong></span>銆?br /> <br /> 銆銆</strong>a.equals(b) 鐨勯粯璁よ涓烘槸鎵ц‘錛濓紳’錛屽寘鎷簡hashCode()鐨勫姣斻傚鏋渆quals()鏂規硶涓嶈override, 閭d箞涓や釜瀵硅薄姘歌繙閮戒笉浼氳涓虹浉鍚屻?br /> <br /> 銆銆2銆HashSet 媯鏌ラ噸澶嶏細hashCode() 涓?equals()<br /> <br /> 銆銆褰撴妸瀵硅薄鏀懼叆HashSet鏃訛紝瀹冧細鍏堢敤瀵硅薄鐨刪ashCode()涓庡凡鏈夊厓绱犵殑hashCode()鏉ユ瘮杈冿紝錛堝鏋滄病鏈塷verride榪噃ashCode()鏂規硶錛岄偅涔圚ashSet 浼氳涓哄璞¢棿涓嶉噸澶嶏紝鎴戜滑褰撶劧瑕乷verride鏉ョ‘淇濆璞℃湁鐩稿悓鐨勫鹼級銆傚鏋渉ashCode()鐩稿悓錛屽啀璋冪敤鍏朵腑涓涓殑equals()鏉ユ鏌ュ璞℃槸鍚︾湡鐨勭浉鍚屻傚鏋滃張鐩稿悓浜嗭紝閭d箞鍔犲叆鐨勬搷浣滃氨涓嶄細鍙戠敓銆?br /> <br /> 銆<em style="color: #000080">銆璇存槑錛氭湁鐩稿悓hashCode()鐨勫璞′篃涓嶄竴瀹氭槸鐩哥瓑鐨勶紝鎰熻鏈夌偣鎬紝浣嗙殑紜姝ゃ傚洜涓篽ashCode()鐢ㄧ殑鏄潅鍑戠畻娉曪紝涔熻鍒氬ソ浣垮涓璞℃湁浜嗙浉鍚岀殑鏉傚噾鍊箋傝秺鐑傜殑鏉傚噾綆楁硶瓚婂鏄撶鎾炪傝繖涓睘浜庢暟鎹粨鏋勬柟闈㈢殑闂浜嗐傚叿浣撶殑瑕侀棶涓撳浜嗐?br /> </em> <img src ="http://www.tkk7.com/yiqi801218/aggbug/213484.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/yiqi801218/" target="_blank">BlueSunshine</a> 2008-07-09 02:47 <a href="http://www.tkk7.com/yiqi801218/archive/2008/07/09/213484.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍝︼紝涓婄彮涓婄彮http://www.tkk7.com/yiqi801218/archive/2008/07/08/213476.htmlBlueSunshineBlueSunshineTue, 08 Jul 2008 15:39:00 GMThttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213476.htmlhttp://www.tkk7.com/yiqi801218/comments/213476.htmlhttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213476.html#Feedback0http://www.tkk7.com/yiqi801218/comments/commentRss/213476.htmlhttp://www.tkk7.com/yiqi801218/services/trackbacks/213476.html
浠婂勾2鏈?鏃ワ紝鏄勾鍓嶇殑鏈鍚庝竴澶╁伐浣滄棩銆?br />
7鏈?鏃ヨ搗錛屽張寮濮嬩簡鏂扮殑宸ヤ綔錛屾崲涓湴鏂癸紝鍦ㄤ笂嫻楓傚垵鍒頒笂嫻鳳紝鏆備綇鍦ㄥ悓浜嬮偅閲屻?

BlueSunshine 2008-07-08 23:39 鍙戣〃璇勮
]]>
絎竴嬈′嬌鐢ㄥ閫夋http://www.tkk7.com/yiqi801218/archive/2008/07/08/213340.htmlBlueSunshineBlueSunshineTue, 08 Jul 2008 07:31:00 GMThttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213340.htmlhttp://www.tkk7.com/yiqi801218/comments/213340.htmlhttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213340.html#Feedback0http://www.tkk7.com/yiqi801218/comments/commentRss/213340.htmlhttp://www.tkk7.com/yiqi801218/services/trackbacks/213340.html box.html:

<body>
<form action="box.jsp" method="post">
  
<p>
  
<input name="box" type="checkbox"  value="box1" />
  box1
  
</p>
  
<p>
    
<input name="box" type="checkbox"  value="box2" />
  box2
</p>
  
<p>
    
<input name="box" type="checkbox"  value="box3" />
  box3
</p>
  
<p>
    
<label>
    
<input type="submit" name="Submit" value="鎻愪氦" />
    
</label>    
    
</p>
</form>
</body>

box.jsp:

<%
String[] box=request.getParameterValues("box");
    
for(String b:box){
        out.print(b
+"<br/>");
    }
%>

鏄劇ず涓猴細

box1
box2
box3

銆銆鍦╢orm涓殑checkbox鐨刵ame灞炴ч兘鍐欐垚鍚屼竴涓悕瀛楋細box 錛岀劧鍚庡湪鐢╮equest.getParameterValues() 鍙栧埌涓涓猄tring[]銆傦紙娉細涓嶆槸request.getParameter()錛?br />
銆銆榪樻湁涓涓棶棰樻病鏈夎В鍐籌紝“閫夋嫨鍏ㄩ儴”闂錛屾兂娉曟槸鐢╦query鏉ュ畬鎴愩?

BlueSunshine 2008-07-08 15:31 鍙戣〃璇勮
]]>
Controller鏂囦歡涓殑return緇撴灉錛氭兂鍔犲鍔狅紝鑰屼笉鏄璺寵漿錛屾庝箞鍋氾紵http://www.tkk7.com/yiqi801218/archive/2008/07/08/213331.htmlBlueSunshineBlueSunshineTue, 08 Jul 2008 06:51:00 GMThttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213331.htmlhttp://www.tkk7.com/yiqi801218/comments/213331.htmlhttp://www.tkk7.com/yiqi801218/archive/2008/07/08/213331.html#Feedback0http://www.tkk7.com/yiqi801218/comments/commentRss/213331.htmlhttp://www.tkk7.com/yiqi801218/services/trackbacks/213331.html
銆銆鎬濊冩柟鍚戞湁璇紝鍙鍦╤tml 涓殑form琛ㄥ崟鍔犱笂銆target="_blank"銆閫夐」灝辮浜嗐?

BlueSunshine 2008-07-08 14:51 鍙戣〃璇勮
]]>
鍚岀被鍨嬫暟緇刟,b, a涓篵鐨勫瓙闆嗭紝姹傚嚭a鐨勮ˉ闆?/title><link>http://www.tkk7.com/yiqi801218/archive/2008/07/01/211983.html</link><dc:creator>BlueSunshine</dc:creator><author>BlueSunshine</author><pubDate>Tue, 01 Jul 2008 10:29:00 GMT</pubDate><guid>http://www.tkk7.com/yiqi801218/archive/2008/07/01/211983.html</guid><wfw:comment>http://www.tkk7.com/yiqi801218/comments/211983.html</wfw:comment><comments>http://www.tkk7.com/yiqi801218/archive/2008/07/01/211983.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/yiqi801218/comments/commentRss/211983.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/yiqi801218/services/trackbacks/211983.html</trackback:ping><description><![CDATA[<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #000000">User[] a;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />User[] b;<br /> <img id="Codehighlighter1_20_31_Open_Image" onclick="this.style.display='none'; Codehighlighter1_20_31_Open_Text.style.display='none'; Codehighlighter1_20_31_Closed_Image.style.display='inline'; Codehighlighter1_20_31_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_20_31_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_20_31_Closed_Text.style.display='none'; Codehighlighter1_20_31_Open_Image.style.display='inline'; Codehighlighter1_20_31_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span id="Codehighlighter1_20_31_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_20_31_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />a,b 璧嬪?br /> <img src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /></span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><img src="http://www.tkk7.com/Images/dot.gif" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">灝哸,b杞崲鎴怱et鍨嬶紝榪欓噷杞崲a,b鐨勬柟娉曚笉鍚?/span><span style="color: #008000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #000000">List</span><span style="color: #000000"><</span><span style="color: #000000">User</span><span style="color: #000000">></span><span style="color: #000000"> aList</span><span style="color: #000000">=</span><span style="color: #000000">Arrays.asList(a);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />Set</span><span style="color: #000000"><</span><span style="color: #000000">User</span><span style="color: #000000">></span><span style="color: #000000"> aSet</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> HashSet</span><span style="color: #000000"><</span><span style="color: #000000">User</span><span style="color: #000000">></span><span style="color: #000000">();<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />aSet.addAll(aList);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />Set</span><span style="color: #000000"><</span><span style="color: #000000">User</span><span style="color: #000000">></span><span style="color: #000000"> bSet</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> HashSet</span><span style="color: #000000"><</span><span style="color: #000000">user</span><span style="color: #000000">></span><span style="color: #000000">();<br /> <img id="Codehighlighter1_206_223_Open_Image" onclick="this.style.display='none'; Codehighlighter1_206_223_Open_Text.style.display='none'; Codehighlighter1_206_223_Closed_Image.style.display='inline'; Codehighlighter1_206_223_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_206_223_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_206_223_Closed_Text.style.display='none'; Codehighlighter1_206_223_Open_Image.style.display='inline'; Codehighlighter1_206_223_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">for</span><span style="color: #000000">(User u:b)</span><span id="Codehighlighter1_206_223_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.tkk7.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_206_223_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />  bSet.add(u);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">姹傚瓙闆?/span><span style="color: #008000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #000000">bSet.removeAll(aSet);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">return</span><span style="color: #000000"> bSet;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <br /> 銆銆榪欓噷鍏堢敤鍒頒簡Arrays鐨勯潤鎬佹柟娉昦sList()錛涳紙Arrays涓嶢rray鐨勫叧緋伙紝鍙傜収Collection涓嶤ollections鐨勫叧緋伙級銆?br /> 銆銆鍐嶇敤鍒頒簡Set 鐨剅emoveAll(Conllection<?> c) 錛岃繖涓柟娉曠殑榪斿洖鍊兼槸boolean鍨嬶紝縐婚櫎 set 涓偅浜涘寘鍚湪鎸囧畾 collection 涓殑鍏冪礌錛堝彲閫夋搷浣滐級銆傚鏋滄寚瀹氱殑 collection 涔熸槸涓涓?set錛屽垯姝ゆ搷浣滀細瀹為檯淇敼姝?set錛岃繖鏍峰叾鍊兼槸涓や釜 set 鐨勪竴涓?em>涓嶅縐板樊闆?/em>銆?java API) <img src ="http://www.tkk7.com/yiqi801218/aggbug/211983.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/yiqi801218/" target="_blank">BlueSunshine</a> 2008-07-01 18:29 <a href="http://www.tkk7.com/yiqi801218/archive/2008/07/01/211983.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://6000cpkj.com" target="_blank">美女的胸又黄又www网站免费</a>| <a href="http://xp189.com" target="_blank">h视频免费高清在线观看</a>| <a href="http://yg1617.com" target="_blank">免费无遮挡无码视频网站</a>| <a href="http://wkk3.com" target="_blank">婷婷亚洲综合一区二区</a>| <a href="http://gxshenquan.com" target="_blank">亚洲一区日韩高清中文字幕亚洲</a>| <a href="http://83k5.com" target="_blank">国产羞羞的视频在线观看免费</a>| <a href="http://djyvp32.com" target="_blank">亚洲国产日韩女人aaaaaa毛片在线</a>| <a href="http://ygpx6.com" target="_blank">成人免费视频88</a>| <a href="http://bb927bb.com" target="_blank">亚洲免费无码在线</a>| <a href="http://szgyk.com" target="_blank">91午夜精品亚洲一区二区三区</a>| <a href="http://33sse.com" target="_blank">免费看一级做a爰片久久</a>| <a href="http://cz655.com" target="_blank">久久久精品午夜免费不卡</a>| <a href="http://276194.com" target="_blank">亚洲AV无码一区二区三区在线</a>| <a href="http://zzjiji.com" target="_blank">亚洲国产精品人人做人人爱</a>| <a href="http://jhc2go.com" target="_blank">青青草原1769久久免费播放</a>| <a href="http://xyjxnhcl.com" target="_blank">亚洲av无码成人精品国产</a>| <a href="http://326h.com" target="_blank">亚洲国产精品无码AAA片</a>| <a href="http://3t77.com" target="_blank">成人毛片视频免费网站观看</a>| <a href="http://cao8080.com" target="_blank">国产又黄又爽胸又大免费视频</a>| <a href="http://gw311.com" target="_blank">亚洲激情视频图片</a>| <a href="http://luyifeile.com" target="_blank">在线亚洲97se亚洲综合在线</a>| <a href="http://cctv69.com" target="_blank">黄色片在线免费观看</a>| <a href="http://jipiao020.com" target="_blank">亚洲精品黄色视频在线观看免费资源 </a>| <a href="http://246210.com" target="_blank">成人午夜亚洲精品无码网站</a>| <a href="http://www-959kj.com" target="_blank">18勿入网站免费永久</a>| <a href="http://556228.com" target="_blank">一级做a爰性色毛片免费</a>| <a href="http://cn-taoqigui.com" target="_blank">亚洲福利秒拍一区二区</a>| <a href="http://16lds.com" target="_blank">亚洲男人的天堂在线va拉文</a>| <a href="http://lookvod.com" target="_blank">成年女人色毛片免费看</a>| <a href="http://jst-hosp.com" target="_blank">99精品视频在线观看免费</a>| <a href="http://jomashopcn.com" target="_blank">噜噜综合亚洲AV中文无码</a>| <a href="http://3344088.com" target="_blank">久久青青草原亚洲av无码app</a>| <a href="http://biarn.com" target="_blank">亚洲成a人片在线观看日本麻豆</a>| <a href="http://426366.com" target="_blank">台湾一级毛片永久免费</a>| <a href="http://sijep.com" target="_blank">a国产成人免费视频</a>| <a href="http://liexion.com" target="_blank">国产精品手机在线亚洲</a>| <a href="http://33sse.com" target="_blank">亚洲www77777</a>| <a href="http://0755haoma.com" target="_blank">亚洲经典在线中文字幕</a>| <a href="http://147v.com" target="_blank">亚洲色无码一区二区三区</a>| <a href="http://beidemei.com" target="_blank">国产精品久久免费视频</a>| <a href="http://fsweicheng.com" target="_blank">久久久久久国产a免费观看黄色大片</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>