java Map ±éÀúËÙ¶È×îÓŽâ
µÚÒ»ÖÖ:
Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
ЧÂʸß,ÒÔºóÒ»¶¨ÒªÊ¹ÓôËÖÖ·½Ê½£¡
µÚ¶þÖÖ:
Map map = new HashMap();
Iterator iter = map.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
Object val = map.get(key);
}
ЧÂʵÍ,ÒÔºó¾¡Á¿ÉÙʹÓã¡
HashMapµÄ±éÀúÓÐÁ½ÖÖ³£Óõķ½·¨£¬ÄǾÍÊÇʹÓÃkeyset¼° entrysetÀ´½øÐбéÀú£¬µ«Á½ÕߵıéÀúËÙ¶ÈÊÇÓвî±ðµÄ£¬ÏÂÃæÇ뿴ʵÀý£º
public class HashMapTest {
public static void main(String[] args) ...{
HashMap hashmap = new HashMap();
for (int i = 0; i < 1000; i ) ...{
hashmap.put("" i, "thanks");
}
long bs = Calendar.getInstance().getTimeInMillis();
Iterator iterator = hashmap.keySet().iterator();
while (iterator.hasNext()) ...{
System.out.print(hashmap.get(iterator.next()));
}
System.out.println();
System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
listHashMap();
}
public static void listHashMap() ...{
java.util.HashMap hashmap = new java.util.HashMap();
for (int i = 0; i < 1000; i ) ...{
hashmap.put("" i, "thanks");
}
long bs = Calendar.getInstance().getTimeInMillis();
java.util.Iterator it = hashmap.entrySet().iterator();
while (it.hasNext()) ...{
java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
// entry.getKey() ·µ»ØÓë´ËÏî¶ÔÓ¦µÄ¼ü
// entry.getValue() ·µ»ØÓë´ËÏî¶ÔÓ¦µÄÖµ
System.out.print(entry.getValue());
}
System.out.println();
System.out.println(Calendar.getInstance().getTimeInMillis() - bs);
}
}
¶ÔÓÚkeySetÆäʵÊDZéÀúÁË2´Î£¬Ò»´ÎÊÇתΪiterator£¬Ò»´Î¾Í´ÓhashmapÖÐÈ¡³ökeyËù¶ÔÓÚµÄvalue¡£¶øentrysetÖ»ÊDZéÀúÁ˵ÚÒ»´Î£¬Ëû°ÑkeyºÍvalue¶¼·Åµ½ÁËentryÖУ¬ËùÒԾͿìÁË¡£
×¢:HashtableµÄ±éÀú·½·¨ºÍÒÔÉϵIJ¶à£¡ ......
Ïà¹ØÎĵµ£º
½«FlexÓëSpring¼¯³Éºó£¨BlazeDS ÓëSpring¼¯³ÉÖ¸ÄÏ £©£¬µÚÒ»¸öÃæÁÙµÄÎÊÌâ¾ÍÊÇ£º¶ÔÓÚJava¶Ë·µ»ØµÄ¸÷ÖÖJavaÀàÐ͵ĶÔÏó£¬FlexÖÐÄÜ·ñÓÐÏàÓ¦µÄÊý¾ÝÀàÐÍÀ´Ó³Éä¡£
´¦Àí£¬ÓÈÆäÊÇList¡¢Set¡¢Map¼°POJO¶ÔÏóÖµ¡£
ÔÚ BlazeDS ÓëSpring¼¯³ÉÖ¸ÄÏ Àý×ӵĻù´¡ÉÏ£¬µ÷ÕûÏà¹ØµÄ²âÊÔ´úÂëÈçÏ£º
1¡¢Java¶Ë
1.1¡¢com.yeeach.HelloWorldService ......
1. µ±Ä³¸öÀàÖеÄij¸ö·½·¨Öеľֲ¿±äÁ¿µÄÃû×ÖÓë¸ÃÀàÖеÄÈ«¾Ö±äÁ¿µÄÃû×ÖÏàͬʱ ¸ÃÈ«¾Ö±äÁ¿½«±»Òþ²Ø£»´Ëʱ Èç¹ûÏëÔڸ÷½·¨ÖÐʹÓÃÈ«¾Ö
±äÁ¿ ±ØÐëʹÓùؼü×Ö£¨this.È«¾Ö±äÁ¿Ãû£©
2. µ±this¹Ø¼ü×Ö³öÏÖÔÚÀàµÄʵÀý·½·¨ÖÐʱ£¬´ú±íÕýÔÚµ÷Óø÷½·¨µÄµ±Ç°¶ÔÏó
3.  ......
Ò»¡¢Àí½â¶àÏß³Ì
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆΪһ¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£Ïß³ÌÓÖ³ÆΪÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖеÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨ ......
1.InputStreamºÍOutputStreamÊÇÓÃÓÚ¶Á»òдµ¥¸ö×Ö½Ú»òÕß×Ö½ÚÊý×飬ÎÒÃǺÜÉÙÓõ½ËüÃǵķ½·¨£¬ËüÃÇÖ®ËùÒÔ´æÔÚÊÇÒòΪ±ðµÄÀà¿ÉÒÔʹÓÃËüÃÇ£¬ÒÔ±ãÌṩ¸üÓÐÓõĽӿڡ£Òò´Ë£¬ÎÒÃǺÜÉÙʹÓõ¥Ò»µÄÀàÀ´´´½¨Á÷¶ÔÏ󣬶øÊÇͨ¹ýµþºÏ¶à¸ö¶ÔÏóÀ´ÌṩËùÆÚÍûµÄ¹¦ÄÜ¡£
2.FilterInputStreamºÍFilterOutputStreamÊÇÓÃÀ´ÌṩװÊÎÆ÷Àà½Ó¿ÚÒÔ¿ØÖÆÌض¨ ......
ʹÓÃJava²Ù×÷Îı¾ÎļþµÄ·½·¨Ïê½â
ÕªÒª: ×î³õjavaÊDz»Ö§³Ö¶ÔÎı¾ÎļþµÄ´¦ÀíµÄ£¬ÎªÁËÃÖ²¹Õâ¸öȱº¶¶øÒýÈëÁËReaderºÍWriterÁ½¸öÀà
×î³õjavaÊDz»Ö§³Ö¶ÔÎı¾ÎļþµÄ´¦ÀíµÄ£¬ÎªÁËÃÖ²¹Õâ¸öȱº¶¶øÒýÈëÁËReaderºÍWriterÁ½¸öÀ࣬ÕâÁ½¸öÀ඼ÊdzéÏóÀ࣬WriterÖÐ write(char[] ch,int off,int
length)£¬flush()ºÍclose()·½·¨Îª³éÏó·½· ......