Groovy javaµÄºÃ»ï°é5
ͨ¹ý Groovy ½øÐÐÑ»·
ͬ´ó¶àÊý½Å±¾ÓïÑÔÒ»Ñù£¬Groovy ¾³£±»Ðû´«ÎªÉú²úÁ¦¸ü¸ß µÄ Java ÓïÑÔÌæ´úÆ·¡£ÄúÒѾ¿´µ½ÁË Groovy ȱÉÙÀàÐÍÄܹ»ÈçºÎ¼õÉÙ´ò×Ö¹¤×÷¡£ÔÚÕâÒ»½Ú£¬½«´´½¨²¢ÊÔÓÃÒ»¸ö repeat º¯Êý¡£ÔÚÕâ¸ö¹ý³ÌÖУ¬½«½øÒ»²½Ì½Ë÷ Groovy Ìá¸ßЧÂʵķ½Ê½¡£
¸üºÃ¡¢¸ü¶ÌµÄÑ»·
ÏÂÃæÕâÖÖ·½·¨¿ÉÒÔ¸üºÃµØ¸ÐÊÜ Groovy ȱ·¦ÀàÐ͵ĺô¦£ºÊ×ÏÈ£¬ÓÃÓë´´½¨ HelloWorld ÏàͬµÄ·½Ê½´´½¨Ò»¸ö Groovy À࣬½«Õâ¸öÀà³ÆΪ MethodMadness£¬²¢É¾³ý×Ô¶¯Éú³ÉµÄÀàÌ壺½«Òª¶¨ÒåÒ»¸ö¶ÀÁ¢µÄ repeat º¯Êý¡£ÏÖÔÚÔÚ¿ØÖÆ̨ÖÐÊäÈëÒÔÏ´úÂ룺
def repeat(val){
for(i = 0; i < 5; i++){
println val
}
}
Æð³õ£¬´Ó Java µÄ½Ç¶ÈÀ´¿´£¬Õâ¸öСº¯Êý¿´ÆðÀ´¿ÉÄÜÓÐЩ¹Ö£¨Êµ¼ÊÉÏ£¬ËüºÜÏñ JavaScript£©¡£µ«Ëü¾ÍÊÇ Java ´úÂ룬ֻ²»¹ýÊÇÓà Groovy µÄÑùʽ±àдµÄ¡£
ÉîÈë·½·¨
repeat º¯Êý½ÓÊÜÒ»¸ö±äÁ¿ val¡£Çë×¢Òâ²ÎÊý²»ÐèÒª def¡£·½·¨Ìå±¾ÖÊÉϾÍÊÇÒ»¸ö for Ñ»·¡£
µ÷ÓÃÕâ¸öº¯Êý¡£
repeat("hello world")
»áÊä³ö “hello world” Îå´Î¡£Çë×¢Ò⣬for Ñ»·ÖÐÊ¡ÂÔÁË int¡£
ûÓбäÁ¿ÀàÐ굀 for Ñ»·Òª±È±ê×¼µÄ Java ´úÂë¶ÌЩ¡£ÏÖÔÚ¿´¿´Èç¹ûÔÚ´úÂëÀï¼ÓÈ뷶Χ»á³öÏÖʲôÇé¿ö¡£
Groovy Öеķ¶Î§
·¶Î§ ÊÇһϵÁеÄÖµ¡£ÀýÈç “0..4” ±íÃ÷°üº¬ ÕûÊý 0¡¢1¡¢2¡¢3¡¢4¡£Groovy »¹Ö§³ÖÅųý·¶Î§£¬“0..<4” ±íʾ 0¡¢1¡¢2¡¢3¡£»¹¿ÉÒÔ´´½¨×Ö·û·¶Î§£º“a..e” Ï൱ÓÚ a¡¢b¡¢c¡¢d¡¢e¡£“a..<e” °üÀ¨Ð¡ÓÚ e µÄËùÓÐÖµ¡£
Ñ»··¶Î§
·¶Î§ÎªÑ»·´øÀ´Á˺ܴóµÄ·½±ã¡£ÀýÈ磬ǰÃæ´Ó 0 µÝÔöµ½ 4 µÄ for Ñ»·ÈçÏÂËùʾ£º
for(i = 0; i < 5; i++)
·¶Î§¿ÉÒÔ½«Õâ¸ö for Ñ»·±äµÃ¸ü¼ò½à£¬¸üÒ×ÔĶÁ£º
def repeat(val){
for(i in 0..5){
println val
}
}
ÉèÖ÷¶Î§
Èç¹ûÔËÐÐÕâ¸öʾÀý£¬¿ÉÄÜ»á×¢Òâµ½Ò»¸öСÎÊÌ⣺“Hello World” Êä³öÁËÁù´Î¶ø²»ÊÇÎå´Î¡£Õâ¸öÎÊÌâÓÐÈýÖÖ½â¾ö·½·¨£º
½«°üº¬µÄ·¶Î§ÏÞÖƵ½ 4£º
for(i in 0..4)
´Ó 1 ¶ø²»ÊÇ 0 ¿ªÊ¼£º def repeat(val){
for(i in 1..5){
println val
}
}
½«·¶Î§ÓÉ°üº¬¸ÄΪÅųý£º
def repeat(val){
for(i in 0..<5){
println val
}
}
²»ÂÛ²ÉÓÃÄÄÖÖ·½·¨£¬¶¼»áµÃµ½ÔÀ´µÄЧ¹û — Êä³ö “Hello World” Îå´Î¡£
ĬÈϲÎÊýÖµ
ÏÖÔÚÒѾ³É¹¦µØʹÓà Groovy µÄ·¶Î§±í´ïʽËõ¶ÌÁË repeat º¯Êý¡£µ«Õâ¸öº¯ÊýÒÀÈ»ÓÐЩÏÞÖÆ¡£Èç¹ûÏëÖظ´ “Hello World&rd
Ïà¹ØÎĵµ£º
2008 Äê 6 ÔÂ 24 ÈÕ
ÔÎĵØÖ·£º http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
±¾ÎĽéÉÜ IBM FileNet P8 4.0 Platform ÌṩµÄ Content Java API¡£Ê×ÏÈ¶Ô FileNet P8 Content Engine ºÍ API ½øÐиÅÒª½éÉÜ, ²¢ËµÃ÷ÁËһЩ»ù±¾¸ÅÄËæºóÏêϸ½éÉÜÁË FileNet Content EngineÌṩµÄ»ùÓÚ EJB ......
Ò»¡¢Java¶àÏ̻߳¥³â¼°Í¬²½¿ØÖƺÍͨÐÅ
¶à¸öÏ̵߳ÄÖ´ÐÐÊDz¢·¢µÄ£¬Ò²¾ÍÊÇÔÚÂß¼Éϓͬʱ”£¬¶ø²»¹ÜÊÇ·ñÊÇÎïÀíÉϵēͬʱ”¡£Èç¹ûϵͳֻÓÐÒ»¸öCPU£¬ÄÇôÕæÕýµÄ“ͬʱ”ÊDz»¿ÉÄܵģ¬µ«ÊÇÓÉÓÚCPUµÄËٶȷdz£¿ì£¬Óû§¸Ð¾õ²»µ½ÆäÖеÄÇø±ð£¬Òò´ËÎÒÃÇÒ²²»ÓùØÐÄËü£¬Ö»ÐèÒªÉèÏë¸÷¸öÏ ......
java ͨ¹ýSystem.getProperties()»ñȡϵͳ²ÎÊý
Properties props=System.getProperties(); //ϵͳÊôÐÔ
System.out.println("JavaµÄÔËÐл·¾³°æ±¾£º"+props.getProperty("java.version"));
System.out.println("JavaµÄÔËÐл·¾³¹©Ó¦ÉÌ£º"+props.getProperty("java.vendor"));
......
Java codeFormat ft=Format.getRawFormat();
ft.setEncoding("utf-8");
ft.setIndent(" ");//ÉèÖÃËõ½ø
XMLOutputter outputter=new XMLOutputter(ft);//ÉèÖÃXML¸ñʽ
Õâλ˵µÄ²»´í£»
ÔÚieÀïÃ棬ËüÄÜ°Ñxml×Ô¶¯½âÎö³ÆÊ÷Ðνṹ£¬ËùÒÔ¿´ÆðÀ´Ã»ÎÊÌ⣬ÔÚ¼Çʱ¾ÀïÃ棬¾Í²»ÐÐÁ ......
ºÜ¿ÉÄܽ« Groovy µ±³ÉÊÇûÓйæÔòµÄ Java ´úÂë¡£µ«Êµ¼ÊÉÏ£¬Groovy Ö»ÊǹæÔòÉÙһЩ¡£ÕâÒ»½ÚµÄÖصãÊÇʹÓà Groovy ±àд Java Ó¦ÓóÌÐòʱ¿ÉÒÔ²»Óÿ¼ÂǵÄÒ»¸ö Java ±à³ÌµÄ¾ßÌå·½Ã棺ÀàÐͶ¨Òå¡£
ΪʲôҪÓÐÀàÐͶ¨Ò壿
ÔÚ Java ÖУ¬Èç¹ûÒªÉùÃ÷Ò»¸ö String ±äÁ¿£¬Ôò±ØÐëÊäÈ룺
String value = "Hello World";
µ«ÊÇ£¬Èç¹û×ÐϸÏëÏ ......