Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java 7µÄÐÂÌØÐÔ

ÎÒ¸Õ´ÓÔÚAntwerpÕÙ¿ªµÄDevoxx
´ó»áÉÏ»ØÀ´£¬»áÉϽéÉÜÁËJava7µÄÐÂÌØÐÔ£¬¶ÔÓ¦µÄJDK½«ÓÚ2010Äê9Ô·¢²¼¡£
ÏÂÃæÊÇ7¸öÒѾ­Íê³ÉµÄÐÂÌØÐÔ£º
¶ÔcollectionsµÄÓïÑÔ¼¶Ö§³Ö
×Ô¶¯×ÊÔ´¹ÜÀí
¸Ä½ø·ºÐÍÔÚ´´½¨ÊµÀýʱµÄÀàÐÍÒýÓÃ
´øÏ»®ÏßµÄÊý×Ö
ÔÚswitchÖÐʹÓÃString
¶þ½øÖÆÎÄ×Ö
¼ò»¯µÄ¿É±ä²ÎÊý·½·¨µ÷ÓÃ
Java7»¹ÓкܶàÆäËûµÄÐÂÌØÐÔ£¬ÎÒ½«»á¶Ô´Ë½øÐÐ×·×Ù¡£
¶ÔCollectionsµÄÓïÑÔ¼¶Ö§³Ö
Java½«»á³ÉΪµÚÒ»¸ö¶ÔCollections´´½¨Ìṩ֧³ÖµÄÓïÑÔ¡£ÕâÒâζ×ÅÔÚjavaÖпÉÒÔÏñRuby, PerlÄÇÑù´´½¨collection¡£
Java7֮ǰµÄ´úÂ룺
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");
Java7µÄ´úÂ룺
List<String> list = ["item"];
String item = list[0];
Set<String> set = {"item"};
Map<String, Integer> map = {"key" : 1};
int value = map["key"];
ÕâЩcollectionsÊDz»¿É±äµÄ¡£
×Ô¶¯×ÊÔ´¹ÜÀí
ÔÚJavaÖÐÏñInputStream, Writers, Sockets, Sql classesµÈÕâÑùµÄÐí¶à×ÊÔ´ÐèÒªÊÖ¶¯¹Ø±Õ£¬×Ô¶¯×ÊÔ´¹ÜÀíµÄÐÂÌØÐÔ£¬ÔÊÐíÔÚtryÓï¾äÖдò¿ª×ÊÔ´£¬²¢×Ô¶¯¹Ø±Õ¡£
֮ǰµÄ´úÂ룺
BufferedReader br = new BufferedReader(new FileReader(path));
try {
return br.readLine();
} finally {
br.close();
}
Java7µÄ´úÂ룺
try (BufferedReader br = new BufferedReader(new FileReader(path)) {
return br.readLine();
}
ÄãÒ²¿ÉÒÔÏñÏÂÃæÕâÑù´ò¿ª¶à¸ö×ÊÔ´£º
try (
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest))
{
// code
}
Ϊ֧³ÖÕâÒ»ÐÂÌØÐÔ£¬ËùÓеĿɹرյÄÀàÐèҪʵÏÖClosable
½Ó¿Ú¡£
¸Ä½ø·ºÐÍÔÚ´´½¨ÊµÀýʱµÄÀàÐÍÒýÓÃ
java7֮ǰµÄ·ºÐÍÔÚ´´½¨ÊµÀýʱÐèҪʹÓÃÈçÏ´úÂ룺
Map<String, List<String>> anagrams = new HashMap<String, List<String>>();
ÔÚJava7ÖУ¬¿ÉÒÔ¼ò»¯³ÉÈçÏ´úÂ룺
Map<String, List<String>> anagrams = new HashMap<>();
“<>”²Ù×÷·


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

¹ØÓÚJavaÕ»Óë¶ÑµÄ˼¿¼

 
­×÷ÕߣºÎ´Öª À´Ô´£ºÔ¹âÈí¼þÕ¾ ¼ÓÈëʱ¼ä£º2005-5-13¡¡Ô¹âÈí¼þÕ¾
­
Ô­Ì⣺ ¹ØÓÚJavaÕ»Óë¶ÑµÄ˼¿¼[/B] ­
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJava[/B]ÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java[/B]×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£ ­
­
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ ......

Java Socket ³¤Á¬½ÓͨÐÅ

 ×î½üÏîÄ¿ÖÐÓиöÐèÇó£¬ÒªÓÃSocketʵÏÖ³¤Á¬½Ó£¬²¢ÇÒÔÚͨÐŹý³ÌÖÐÒª»¥ÎªserverºÍclient£¬¼´ÔÚÒ»¸öÁ¬½ÓÖУ¬¼ÈÄܹ»·¢ËÍÏûÏ¢£¬£¨´Ëʱ×÷Ϊ¿Í»§¶Ë£©£¬ÓÖÒªÄܹ»½ÓÊÕÏûÏ¢£¨´Ëʱ×÷Ϊserver¶Ë£©£¬Ñо¿ÁËÏ£¬ÊµÏÖ·½Ê½ÈçÏ£º
Ò»¡¢·¢ËÍÏûϢʱ½¨Á¢Á¬½Ó£¬¹¹½¨Í¨µÀ¡£
Socket socket = new Socket();
SocketAddress endpoint = new In ......

javaÁ¬½ÓÊý¾Ý¿â

1.javaÁ¬½ÓOracleÊý¾Ý¿â£º
 Class.forName("oracle.jdbc.driver.OracleDriver");
 String url="jdbc:oracle:thin:@127.0.0.1:1521:È«¾ÖÊý¾Ý¿âÃû";
 String uname="Óû§Ãû";
 String pwd="ÃÜÂë";
 Connection cn =DriverManager.getConnection(url,uname,pwd);
 Statement s=cn.createS ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ