ÃæÏòJava¿ª·¢ÈËÔ±µÄScalaÖ¸ÄÏ - °üºÍ·ÃÎÊÐÞÊηû - ±à³ÌÈëÃÅÍø
ÃæÏòJava¿ª·¢ÈËÔ±µÄScalaÖ¸ÄÏ - °üºÍ·ÃÎÊÐÞÊηûʱ¼ä:2011-01-30 Ted Neward×î½ü£¬¶ÁÕߵķ´À¡ÈÃÎÒÒâʶµ½ÔÚÖÆ×÷±¾ÏµÁеĹý³ÌÖÐÎÒÒÅ©ÁË Scala µÄÓïÑÔµÄÒ»¸öÖØÒª·½Ã棺Scala µÄ°üºÍ·ÃÎÊÐÞÊηû¹¦ÄÜ¡£ËùÒÔÔÚÑо¿¸ÃÓïÑԵĺ¯ÊýÐÔÔªËØ apply »úÖÆÇ°£¬ÎÒ½«ÏȽéÉÜ°üºÍ·ÃÎÊÐÞÊηû¡£ ´ò°ü ΪÁËÓÐÖúÓÚ¸ôÀë´úÂ룬ʹÆä²»»áÏ໥³åÍ»£¬Java™ ´úÂëÌṩÁË package ¹Ø¼ü´Ê£¬ÓÉ´Ë´´½¨ÁËÒ»¸ö´Ê·¨ÃüÃû¿Õ¼ä£¬ÓÃÒÔÉùÃ÷Àà¡£±¾ÖÊÉÏ£¬½«Àà Foo ·ÅÖõ½ÃûΪ com.tedneward.util °üÖоͽ«ÕýʽÀàÃûÐ޸ijÉÁË com.tedneward.util.Foo£»Í¬Àí£¬±ØÐë°´¸Ã·½·¨ÒýÓÃÀà¡£Èç¹ûûÓУ¬Java ±à³ÌÈËÔ±»áºÜ¿ìÖ¸³ö£¬ËûÃÇ»á import ¸Ã°ü£¬±ÜÃâ¼üÈëÕýʽÃûµÄÂé·³¡£µÄÈ·Èç´Ë£¬µ«Õâ½öÒâζןù¾ÝÕýʽÃûÒýÓÃÀàµÄ¹¤×÷ÓɱàÒëÆ÷ºÍ×Ö½ÚÂëÍê³É¡£¿ìËÙä¯ÀÀһϠjavap µÄÊä³ö£¬Õâµã¾Í»áºÜÃ÷ÁË¡£ È»¶ø£¬Java ÓïÑÔÖеİü»¹Óм¸¸öÌØÊâµÄÒªÇó£ºÒ»¶¨ÒªÔÚ°üËù×÷ÓõÄÀàËùÔÚµÄ .java ÎļþµÄ¶¥¶ËÉùÃ÷°ü£¨ÔÚ½«×¢ÊÍÓ¦ÓÃÓÚ°üʱ£¬ÕâÒ»µã»áÒý·¢ºÜÑÏÖصÄÓïÑÔÎÊÌ⣩£»¸ÃÉùÃ÷µÄ×÷ÓÃÓòΪÕû¸öÎļþ¡£ÕâÒâζ×ÅÁ½¸ö¿ç°ü½øÐнôÃÜñîºÏµÄÀàÒ»¶¨ÒªÔÚ¿çÎļþʱ·ÖÀ룬Õâ»áÖÂʹÁ½Õß¼äµÄ½ôÃÜñîºÏºÜÈÝÒ×±»ºöÂÔ¡£ Scala ÔÚ´ò°ü·½ÃæËù²ÉÈ¡µÄ·½·¨ÓÐЩ²»Í¬£¬Ëü½áºÏʹÓÃÁË Java ÓïÑ﵀ declaration ·½·¨ºÍ C# µÄ scope£¨ÏÞ¶¨×÷ÓÃÓò£©·½·¨¡£Á˽âÁËÕâÒ»µã£¬Java ¿ª·¢ÈËÔ±¾Í¿ÉÒÔʹÓô«Í³µÄ Java ·½·¨²¢½« package ÉùÃ÷·ÅÔÚ .scala ÎļþµÄ¶¥²¿£¬¾ÍÏñÆÕͨµÄ Java ÀàÒ»Ñù£»°üÉùÃ÷µÄ×÷ÓÃÓòΪÕû¸öÎļþ£¬¾ÍÏñÔÚ Java ´úÂëÖÐÒ»Ñù¡£¶ø Scala ¿ª·¢ÈËÔ±Ôò¿ÉÒÔʹÓà Scala µÄ°ü “£¨scoping£©ÏÞ¶¨×÷ÓÃÓò” ·½·¨£¬ÓôóÀ¨ºÅÏÞÖÆ package Óï¾äµÄ×÷ÓÃÓò£¬ÈçÇåµ¥ 1 Ëùʾ£º Çåµ¥ 1. ¼ò»¯µÄ´ò°ü
Õâ¸ö´úÂëÓÐЧµØÉùÃ÷ÁËÀà App£¬»òÕ߸üÈ·ÇеÄ˵ÊÇÒ»¸ö³ÆΪ com.tedneward.scala.demonstration.App µÄµ¥¸öÀà¡£×¢Òâ Scala »¹ÔÊÐíÓõã·Ö¸ô°üÃû£¬ËùÒÔÇåµ¥ 1 ÖеĴúÂë¿ÉÒÔ¸ü¼ò½à£¬ÈçÇåµ¥ 2 Ëùʾ£º Çåµ¥ 2. ¼ò»¯Á˵Ĵò°ü£¨redux£©
ÓÃÄÄÒ»ÖÖÑùʽ¿´ÆðÀ´¶¼±È½ÏºÏÊÊ£¬ÒòΪËüÃǶ¼±àÒë³öÒ»ÑùµÄ´úÂë¹¹Ô죨Scala ½«¼ÌÐø±àÒë²¢ºÍ javac Ò»ÑùÔÚÉùÃ÷°üµÄ×ÓĿ¼ÖÐÉú³É .class Îļþ£©¡£ ÃæÏòJava¿ª·¢ÈËÔ±µÄScalaÖ¸ÄÏ - °üºÍ·ÃÎÊÐÞÊηû(2)ʱ¼ä:2011-01-30 Ted Newardµ¼Èë Óë°üÏà¶ÔµÄµ±È»¾ÍÊÇ import ÁË£¬Scala ʹÓÃËü½«Ãû³Æ·ÅÈ뵱ǰ´Ê·¨Ãû³Æ¿Õ¼ä¡£±¾ÏµÁеĶÁÕßÒѾÔÚ´ËÇ°µÄºÜ¶àÀý×ÓÖмûµ½¹ý import ÁË£¬µ«ÏÖÔÚÎÒ½«Ö¸³öһЩÈà Java ¿ª·¢ÈËÔ±´ó³ÔÒ»¾ªµÄ import µÄÌØÐÔ¡£ Ê×ÏÈ£¬import ¿ÉÒÔÓÃÓÚ¿Í»§»ú Scala ÎļþÄÚµÄÈκεط½£¬²¢·ÇÖ»¿ÉÒÔÓÃÔÚÎļþµÄ¶¥²¿£¬ÕâÑù¾ÍÓÐÁË×÷ÓÃÓòµÄ¹ØÁªÐÔ¡£Òò´Ë£¬ÔÚÇåµ¥ 3 ÖУ¬java.math.BigInteger µ¼ÈëµÄ×÷ÓÃÓò±»ÍêÈ«ÏÞ¶¨µ½ÁËÔÚ App ¶ÔÏóÄÚ²¿¶¨ÒåµÄ·½·¨£¬ÆäËûµØ·½¶¼²»ÐС£Èç¹û mathfun ÄÚµÄÆäËûÀà»ò¶ÔÏóÒªÏëʹÓà java.math.BigInteger£¬¾ÍÐèÒªÏñ App Ò»Ñùµ¼Èë¸ÃÀà¡£Èç¹û mathfun µÄ¼¸¸öÀ඼ÏëʹÓà |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |
- C#תȫ½Ç°ë½Ç
- C£«£«BuilerÖжàÏ̵߳ÄʵÏÖ
- ÈçºÎʹÓÃËÑË÷ÒýÇæ²éÕÒÐÅÏ¢ ¸üºÃµØËÑË÷
- Spring JDBC³éÏó¿ò¼Ü¼ò»¯WebÊý¾Ý¿â¿ª·¢ - ±à³ÌÈëÃÅÍø
- ʵս£ºsuse9 linuxÏÂmountµÄʹÓÃ
- ϬÀû¸çÃ÷ÐÇÆòؤºì͸ÍøÂçPSÕÕƬȫ¼¯ÐÀÉÍ
- dz̸Swishmax£¨ÍûÄܸø³õѧÕßÒ»µãÆôʾ£©
- ¿ª·¢ÄúµÄµÚÒ»¸öEclipse RCPÓ¦ÓóÌÐò - ±à³ÌÈëÃÅÍø
- Photoshop½Ì³Ì:ÈÃƤ·ô¿´ÆðÀ´¹â»¬Ë®ÄÛ
- SPANºÍDIV,ClassÓëIDµÄÇø±ð»ã×Ü