¡¾×ª¡¿Java 7ÒѾÍê³ÉµÄÆß´óй¦ÄÜÔ¤ÀÀ
×î½üµÄDevoxx´ó»áÉÏ£¬Java 7½«°üº¬±Õ°üµÄÏûÏ¢ÁîºÜ¶àÈ˸е½Õñ·Ü——Õ⽫×öΪһ¸ö¶ÀÁ¢µÄJSR±»ÊµÏÖ¡£ÔÚÖÚ¶àJava 7еÄÓïÑÔÌØÐÔÖУ¬ÓÐһЩÏÖÔÚÒѾÍê³ÉÁË¡£Devoxx´ó»áµÄһλ²Î»áÕßÔÚ²©¿ÍÖб¨¸æÁËÏÂÃæÕâЩJava 7ÒѾÍê³ÉµÄ7´óй¦ÄÜ£º
1£©¶Ô¼¯ºÏÀàµÄÓïÑÔÖ§³Ö£»
2£©×Ô¶¯×ÊÔ´¹ÜÀí£»
3£©¸Ä½øµÄͨÓÃʵÀý´´½¨ÀàÐÍÍƶϣ»
4£©Êý×Ö×ÖÃæÁ¿Ï»®ÏßÖ§³Ö£»
5£©switchÖÐʹÓÃstring£»
6£©¶þ½øÖÆ×ÖÃæÁ¿£»
7£©¼ò»¯¿É±ä²ÎÊý·½·¨µ÷Óá£
ÏÂÃæÎÒÃÇÀ´×Ðϸ¿´Ò»ÏÂÕâ7´óй¦ÄÜ£º
¶Ô¼¯ºÏÀàµÄÓïÑÔÖ§³Ö
Java½«°üº¬¶Ô´´½¨¼¯ºÏÀàµÄµÚÒ»ÀàÓïÑÔÖ§³Ö¡£ÕâÒâζ׿¯ºÏÀàµÄ´´½¨¿ÉÒÔÏñRubyºÍPerlÄÇÑùÁË¡£
Ô±¾ÐèÒªÕâÑù£º
List<String> list = new ArrayList<String>(); list.add("item"); String item = list.get(0); Set<String> set = new HashSet<String>(); set.add("item"); Map<String, Integer> map = new HashMap<String, Integer>(); map.put("key", 1); int value = map.get("key");
ÏÖÔÚÄã¿ÉÒÔÕâÑù£º
List<String> list = ["item"]; String item = list[0]; Set<String> set = {"item"}; Map<String, Integer> map = {"key" : 1}; int value = map["key"];
ÕâЩ¼¯ºÏÊDz»¿É±äµÄ¡£
×Ô¶¯×ÊÔ´¹ÜÀí
JavaÖÐijЩ×ÊÔ´ÊÇÐèÒªÊÖ¶¯¹Ø±ÕµÄ£¬ÈçInputStream£¬Writes£¬Sockets£¬Sql classesµÈ¡£Õâ¸öеÄÓïÑÔÌØÐÔÔÊÐítryÓï¾ä±¾ÉíÉêÇë¸ü¶àµÄ×ÊÔ´£¬ÕâЩ×ÊÔ´×÷ÓÃÓÚtry´úÂë¿é£¬²¢×Ô¶¯¹Ø±Õ¡£
Õâ¸ö£º
BufferedReader br = new BufferedReader(new FileReader(path)); try { return br.readLine(); } finally { br.close(); }
±ä³ÉÁËÕâ¸ö£º
try (BufferedReader br = new BufferedReader(new FileReader(path)) { return br.readLine(); }
Äã¿ÉÒÔ¶¨Òå¹Ø±Õ¶à¸ö×ÊÔ´£º
try (
Ïà¹ØÎĵµ£º
±¾ÎĽéÉÜÁËJavaÄÚ´æÒç³öµÄÏêϸ½â¾ö·½°¸¡£±¾ÎÄ×ܽáÄÚ´æÒç³öÖ÷ÒªÓÐÁ½ÖÖÇé¿ö£¬¶øJVM¾³£µ÷ÓÃÀ¬»ø»ØÊÕÆ÷½â¾öÄÚ´æ¶Ñ²»×ãµÄÎÊÌ⣬µ«ÊÇÓÐʱÈÔ»áÓÐÄÚ´æ²»×ãµÄ´íÎó¡£×÷Õß·ÖÎöÁËJVMÄÚ´æÇøÓò×é³É¼°JVMÉèÖÃÐéÄâÄÚ´æµÄ·½Ê½£¬´Ó¶ø¸ø³öÁËһϵÁнâ¾ö·½°¸¡£ Ò»¡¢ÄÚ´æÒç³öÀàÐÍ 1¡¢java.lang.OutOfMemoryError: PermGen space JVM¹ ......
°Ñ֮ǰÏîÄ¿ÖÐдµÄÒ»¸öJavaͨÓÃÑéÖ¤Âë³ÌÐòÕûÀíÁËһϣ¬Óë´ó¼Ò·ÖÏí£¬Ï£ÍûÄÜÅ×שÒýÓñ¡£
Ò»¡¢Ö÷Òª¹¦ÄÜ£º
1¡¢Ö§³Ö´¿Êý×Ö¡¢´óд×Öĸ¡¢Ð¡Ð´×Öĸ£¬¼°Á½Á½»ìºÏ»òÈýÕß»ìºÏÀàÐÍÑéÖ¤Â룻
2¡¢Ö§³Ö×Ô¶¨ÒåÌØÊâ×Ö·ûÅųý£¨Èç0oOi1jI£©£»
3¡¢Ö§³ÖͼƬ¼°ÎÄ×ÖÁ½ÖÖÀàÐÍÑéÖ¤Â룻
4¡¢Ö§³Ö×Ô¶¨ÒåÑéÖ¤ÂëͼƬ´óС£»
5¡¢Ö§³Ö×Ô¶¨Òå¸ÉÈÅÏßÌõÊý£»
......
quartzÊǸÉɶµÄ£¿ ÈÎÎñµ÷¶ÈÓõÄ
ÈÎÎñµ÷¶ÈÊǸÉɶµÄ£¿¾ÍÊÇÔÚÔ¤¶¨µÄʱ¼ä×öÔ¤¶¨µÄÊÂ
1.ÔÚquartÍøÕ¾ÏÂ×îеÄJAR°ü
2.½¨¸öÏîÄ¿£¬°ÑquartzµÄJAR°ü¼ÓÈëµ½ÏîÄ¿
3.н¨Ò»¸öÈÎÎñ
public class MyJob implements org.quartz.Job {
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionExceptio ......