java ÖÐ Map±éÀú
µÚ¶þÖÖ·½·¨Ð§Âʸü¸ß
·¨¢Ù
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
Àý×Ó£º
package com.cric.cat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class MapTest1 {
public static void main(String[] args) {
Student stu1=new Student("¸æ½ëÈ¥", "Å©´ó");
Student stu2 = new Student("Íù»ù¡", "º£´ó");
Map M = new HashMap();
M.put("jay",stu1);
M.put("wang", stu2);
Iterator it=M.entrySet().iterator();
while(it.hasNext()){
Map.Entry entry=(Map.Entry)it.next();
Object key=entry.getKey();
Object value=entry.getValue();
System.out.println(key);
System.out.println(value);
}
}
}
package com.cric.cat;
public class Student {
private String name;
private String school;
public Student(String name, String school) {
this.name = name;
this.school = school;
}
public String toString() {
return school + "±ÏÒµµÄ" + name;
}
}
·¨¢Ú
HashMap<String, String> map = new HashMap<String, String>();
map.put("jay", stu1.toString());
map.put("wang", stu2.toString());
for (Entry b : map.entrySet()) {
System.out.println(b.getKey());
System.out.println(b.getValue());
Àý×Ó£º
package com.cric.cat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class MapTest {
&
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
JavaÄÚ´æ¹ÜÀí£¨Ò»¡¢ÄÚ´æ·ÖÅ䣩
¹Ø¼ü×Ö: ÄÚ´æ·ÖÅ䣬³£Á¿³Ø
Ò»¡¢JavaÄÚ´æ·ÖÅä
1¡¢ JavaÓм¸ÖÖ´æ´¢ÇøÓò£¿
* ¼Ä´æÆ÷
-- ÔÚCPUÄÚ²¿£¬¿ª·¢ÈËÔ±²»ÄÜͨ¹ý´úÂëÀ´¿ØÖƼĴæÆ÷µÄ·ÖÅ䣬ÓɱàÒëÆ÷À´¹ÜÀí
* Õ»
-- ÔÚWindowsÏÂ, Õ»ÊÇÏòµÍµØÖ·À©Õ¹µÄÊý¾Ý½á¹¹£¬ÊÇÒ»¿éÁ¬ÐøµÄÄÚ´æµÄÇøÓò£¬¼´Õ»¶¥µÄµØÖ ......
Ò»¡¢»ùÓÚRMIµÄÒ»´ÎÍêÕûµÄÔ¶³ÌͨÐŹý³ÌµÄÔÀí£º
1. ¿Í»§¶Ë·¢ÆðÇëÇó£¬ÇëÇóת½»ÖÁRMI¿Í»§¶ËµÄstubÀࣻ
2. stubÀཫÇëÇóµÄ½Ó¿Ú¡¢·½·¨¡¢²ÎÊýµÈÐÅÏ¢½øÐÐÐòÁл¯£»
3. »ùÓÚsocket½«ÐòÁл¯ºóµÄÁ÷´«ÊäÖÁ·þÎñÆ÷¶Ë£»
4. ·þÎñÆ÷¶Ë½ÓÊÕµ½Á÷ºóת·¢ÖÁÏàÓ¦µÄskeltonÀࣻ
5. skeltonÀཫÇëÇóµÄÐÅÏ¢·´ÐòÁл¯ºóµ÷ÓÃʵ¼ÊµÄ´¦ÀíÀࣻ
6. ´¦Àí ......
31¡¢EJB°üÀ¨£¨SessionBean,EntityBean£©Ëµ³öËûÃǵÄÉúÃüÖÜÆÚ£¬¼°ÈçºÎ¹ÜÀíÊÂÎñµÄ£¿
SessionBean£ºStateless Session Bean µÄÉúÃüÖÜÆÚÊÇÓÉÈÝÆ÷¾ö¶¨µÄ£¬µ±¿Í»§»ú·¢³öÇëÇóÒª½¨Á¢Ò»¸öBeanµÄʵÀýʱ£¬EJBÈÝÆ÷²»Ò»¶¨Òª´´½¨Ò»¸öеÄBeanµÄʵÀý¹©¿Í»§»úµ÷Ó㬶øÊÇËæ±ãÕÒÒ»¸öÏÖÓеÄʵÀýÌṩ¸ø¿Í»§»ú¡£µ±¿Í»§»úµÚÒ»´Îµ÷ÓÃÒ»¸öStateful S ......
synchronized¹Ø¼ü×ÖÔÚ¶àÏß³ÌÖеÄ×÷Óãº
Á½ÖÖÓ÷¨£ºsynchronized ·½·¨ºÍ synchronized ¿é¡£
1. synchronized ·½·¨£ºÍ¨¹ýÔÚ·½·¨ÉùÃ÷ÖмÓÈë synchronized¹Ø¼ü×ÖÀ´ÉùÃ÷ synchronized ·½·¨¡£ÈçÉÏÊöÀý×ÓËùÊö¡£
synchronized ·½·¨¿ØÖƶÔÀà³ÉÔ±±äÁ¿µÄ·ÃÎÊ£ºÃ¿¸öÀàʵÀý¶ÔÏó¶ÔÓ¦Ò»°ÑËø£¬Ã¿¸ö synchronized ·½·¨¶¼±ØÐë»ñµÃµ÷Óø÷½· ......