JavaÓÃforÑ環Map
¸ù¾ÝJDK5µÄÐÂÌØÐÔ,ÓÃForÑ»·Map,ÀýÈçÑ»·MapµÄKey
Java´úÂë
for(String dataKey : paraMap.keySet()) {
System.out.println(dataKey );
}
for(String dataKey : paraMap.keySet()) {
System.out.println(dataKey );
}
×¢ÒâµÄÊÇ,paraMap ÊÇÔõôÑù¶¨ÒåµÄ,Èç¹ûÊǼòµ¥µÄMap paraMap = new HashMap ();ÄÇÇ°ÃæµÄString¾ÍÖ»ÄÜ»»³ÉObjectÁË.
Ñ環Õû個mapµÄkeyºÍvalue
Java´úÂë
Map<Integer,String> map = new LinkedHashMap<Integer,String>();
map.put(1, "ÐÇÆÚÒ»");
map.put(2, "ÐÇÆÚ¶þ");
map.put(3, "ÐÇÆÚÈý");
map.put(4, "ÐÇÆÚËÄ");
map.put(5, "ÐÇÆÚÎå");
map.put(6, "ÐÇÆÚÁù");
map.put(7, "ÐÇÆÚÈÕ");
for(Map.Entry<Integer, String> entry: map.entrySet()) {
System.out.print(entry.getKey() + ":" + entry.getValue() + "\t");
}
Map<Integer,String> map = new LinkedHashMap<Integer,String>();
map.put(1, "ÐÇÆÚÒ»");
map.put(2, "ÐÇÆÚ¶þ");
map.put(3, "ÐÇÆÚÈý");
map.put(4, "ÐÇÆÚËÄ");
map.put(5, "ÐÇÆÚÎå");
map.put(6, "ÐÇÆÚÁù");
map.put(7, "ÐÇÆÚÈÕ");
for(Map.Entry<Integer, String> entry: map.entrySet()) {
System.out.print(entry.getKey() + ":" + entry.getValue() + "\t");
}
輸³ö結¹û£º
1:ÐÇÆÚÒ» 2:ÐÇÆÚ¶þ 3:ÐÇÆÚÈý 4:ÐÇÆÚËÄ 5:ÐÇÆÚÎå 6:ÐÇÆÚÁù 7:ÐÇÆÚÈÕ
Ïà¹ØÎĵµ£º
1.дһ¸ö·½·¨£¬ÓÃÒ»¸öforÑ»·´òÓ¡¾Å¾Å³Ë·¨±í
/**
* ´òÓ¡¾Å¾Å³Ë·¨¿Ú¾÷±í
*/
public void nineNineMulitTable(){
for (int i = 1,j = 1; j <= 9; i++) {
System.out.print(i+"*"+j+"="+i*j+" ");
if(i==j){
i=0;
......
javaÖÐʱ¼ä´ÁºÍʱ¼ä×Ö·û´®Ö®¼äµÄת»»
»ñÈ¡µ±Ç°µÄunixʱ¼ä´Á
new Date().getTime()
System.currentTimeMillis()
·µ»ØµÄÊǺÁÃëÊý£¬Òª×ª»»long t = System.currentTimeMillis()/1000;
»ñÈ¡µ±Ç°ÄêÔÂÈÕÒÔ¼°Ê±·ÖÃë
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR)) c.get(Calendar.YEAR)) c.get(C ......
Óû§ÒªÇóͳ¼ÆËùÌṩ¹Ø¼ü×ÖÔÚÍøÂç³öÏÖµÄÐÂÎÅ£¬ÏÂÃæΪһ¸ö²âÊÔµÄmain·½·¨¡£
package com.net;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
impo ......
Ò»¡¢±³¾°
×î½üÒ»Äê¶àÀ´,ÔÚInternetÉϳöÏÖµÄÌرðÎüÒýÈ˵Äʼþ¾ÍÊÇJavaÓïÑÔºÍÓÃJava±àдµÄä¯ÀÀÆ÷HotJava¡£
1991Äê,SUNMicroSystem¹«Ë¾µÄJameGosling¡¢BillJoeµÈÈË,ΪÔÚµçÊÓ¡¢¿ØÖÆ¿¾Ãæ°üÏäµÈ¼ÒÓÃÏû·ÑÀàµç×Ó²úÆ·ÉϽøÐн»»¥Ê½²Ù×÷¶ø¿ª·¢ÁËÒ»¸öÃûΪOakµÄÈí¼þ(¼´Ò»ÖÖÏðÊ÷µÄÃû×Ö),µ«µ±Ê±²¢Ã»ÓÐÒýÆðÈËÃǵ ......
1¡¢JAVA¶ÁÈ¡Îļþ£¬±ÜÃâÖÐÎÄÂÒÂë¡£
/**
* ¶ÁÈ¡ÎļþÄÚÈÝ
*
* @param filePathAndName
* String Èç c:\\1.txt ¾ø¶Ô·¾¶
* @return boolean
*/
public static String readFile(String filePathAndName) {
String fileContent ......