JAVA ¾²Ì¬±äÁ¿Ó뾲̬·½·¨
javaÖо²Ì¬±äÁ¿ºÍ¾²Ì¬·½·¨·Ö±ðÓÐʲôÌص㣿
ÐüÉÍ·Ö£º0 - ½â¾öʱ¼ä£º2006-4-10 10:28
ÌáÎÊÕߣº vv_clear - ¶þ¼¶
×î¼Ñ´ð°¸
ΪʲôÎÊÁËÁ½´Î£¿ÔÙÌùÉÏÁíһƪ
Thinking:JavaÖÐstaticÓ÷¨- -
Tag£º Thinking:JavaÖÐs
Ò»¡¢static
ÇëÏÈ¿´ÏÂÃæÕâ¶Î³ÌÐò£º
public class Hello{
public static void main(String[] args){ //(1)
System.out.println("Hello,world!"); //(2)
}
}
¿´¹ýÕâ¶Î³ÌÐò£¬¶ÔÓÚ´ó¶àÊýѧ¹ýJava µÄ´ÓÀ´Ëµ£¬¶¼²»Ä°Éú¡£¼´Ê¹Ã»ÓÐѧ¹ýJava£¬¶øѧ¹ýÆäËüµÄ¸ß¼¶ÓïÑÔ£¬ÀýÈçC£¬ÄÇÄãÒ²Ó¦¸ÃÄÜ¿´¶®Õâ¶Î´úÂëµÄÒâ˼¡£ËüÖ»ÊǼòµ¥µÄÊä³ö“Hello,world”£¬Ò»µã±ðµÄÓô¦¶¼Ã»ÓУ¬È»¶ø£¬ËüȴչʾÁËstatic¹Ø¼ü×ÖµÄÖ÷ÒªÓ÷¨¡£
ÔÚ1´¦£¬ÎÒÃǶ¨ÒåÁËÒ»¸ö¾²Ì¬µÄ·½·¨ÃûΪmain£¬Õâ¾ÍÒâζןæËßJava±àÒëÆ÷£¬ÎÒÕâ¸ö·½·¨²»ÐèÒª´´½¨Ò»¸ö´ËÀàµÄ¶ÔÏó¼´¿ÉʹÓá£Ä㻹µÃÄãÊÇÔõôÔËÐÐÕâ¸ö³ÌÐòÂð£¿Ò»°ã£¬ÎÒÃǶ¼ÊÇÔÚÃüÁîÐÐÏ£¬´òÈëÈçϵÄÃüÁî(¼ÓÏ»®ÏßΪÊÖ¶¯ÊäÈë)£º
javac Hello.java
java Hello
Hello,world!
Õâ¾ÍÊÇÄãÔËÐеĹý³Ì£¬µÚÒ»ÐÐÓÃÀ´±àÒëHello.javaÕâ¸öÎļþ£¬Ö´ÐÐÍêºó£¬Èç¹ûÄã²é¿´µ±Ç°£¬»á·¢ÏÖ¶àÁËÒ»¸öHello.classÎļþ£¬ÄǾÍÊǵÚÒ»ÐвúÉúµÄJava¶þ½øÖÆ×Ö½ÚÂë¡£µÚ¶þÐоÍÊÇÖ´ÐÐÒ»¸öJava³ÌÐòµÄ×îÆÕ±é×ö·¨¡£Ö´Ðнá¹ûÈçÄãËùÁÏ¡£ÔÚ2ÖУ¬Äã¿ÉÄÜ»áÏ룬ΪʲôҪÕâÑù²ÅÄÜÊä³ö¡£ºÃ£¬ÎÒÃÇÀ´·Ö½âÒ»ÏÂÕâÌõÓï¾ä¡££¨Èç¹ûûÓа²×°JavaÎĵµ£¬Çëµ½SunµÄ¹Ù·½ÍøÕ¾ä¯ÀÀJ2SE API£©Ê×ÏÈ£¬SystemÊÇλÓÚjava.lang°üÖеÄÒ»¸öºËÐÄÀ࣬Èç¹ûÄã²é¿´ËüµÄ¶¨Ò壬Äã»á·¢ÏÖÓÐÕâÑùÒ»ÐУºpublic static final PrintStream out;½Ó×ÅÔÚ½øÒ»²½£¬µã»÷PrintStreamÕâ¸ö³¬Á´½Ó£¬ÔÚMETHODÒ³Ã棬Äã»á¿´µ½´óÁ¿¶¨ÒåµÄ·½·¨£¬²éÕÒprintln£¬»áÓÐÕâÑùÒ»ÐУº
public void println(String x)¡£
ºÃÁË£¬ÏÖÔÚÄãÓ¦¸ÃÃ÷°×ΪʲôÎÒÃÇÒªÄÇÑùµ÷ÓÃÁË£¬outÊÇSystemµÄÒ»¸ö¾²Ì¬±äÁ¿£¬ËùÒÔ¿ÉÒÔÖ±½ÓʹÓ㬶øoutËùÊôµÄÀàÓÐÒ»¸öprintln·½·¨¡£
¾²Ì¬·½·¨
ͨ³££¬ÔÚÒ»¸öÀàÖж¨ÒåÒ»¸ö·½·¨Îªstatic£¬ÄǾÍÊÇ˵£¬ÎÞÐè±¾ÀàµÄ¶ÔÏ󼴿ɵ÷Óô˷½·¨¡£ÈçÏÂËùʾ£º
class Simple{
static void go(){
System.out.println("Go...");
}
}
public class Cal{
public static void main(String[] args){
Simple.go();
}
}
µ÷ÓÃÒ»¸ö¾²Ì¬·½·¨¾ÍÊÇ“ÀàÃû.·½·¨Ãû”,¾²Ì¬·½·¨µÄʹÓúܼòµ¥ÈçÉÏËùʾ¡£Ò»°ãÀ´Ëµ£¬¾²Ì¬·½·¨³£³
Ïà¹ØÎĵµ£º
Ò»¸öÈí¼þÉè¼ÆµÄºÃ»µ£¬ÎÒÏëºÜ´ó³Ì¶ÈÉÏÈ¡¾öÓÚËüµÄÕûÌå¼Ü¹¹£¬¶øÕâ¸öÕûÌå¼Ü¹¹Æäʵ¾ÍÊÇÄã¶ÔÕû¸öºê¹ÛÉÌÒµÒµÎñµÄ³éÏó¿ò¼Ü£¬µ±´ú±íÒµÎñÂß¼µÄ¸ß²ã³éÏó²ã½á¹¹ ºÏÀíʱ£¬Äãµ×²ãµÄ¾ßÌåʵÏÖÐèÒª¿¼Âǵľͽö½öÊÇһЩËã·¨ºÍһЩ¾ßÌåµÄÒµÎñʵÏÖÁË¡£µ±ÄãÐèÒªÔÙ¿ª·¢ÁíÒ»¸öÏà½üµÄÏîĿʱ£¬ÄãÒÔÇ°µÄ³éÏó²ã˵²»¶¨»¹¿ÉÒÔÔÙ´ÎÀûÓà ÄØ£¬Ãæ¶Ô¶ÔÏóµÄÉè¼Æ ......
1¡¢FACTORY—×·MMÉÙ²»ÁËÇë³Ô·¹ÁË£¬Âóµ±À͵ļ¦³áºÍ¿ÏµÂ»ùµÄ¼¦³á¶¼ÊÇMM°®³ÔµÄ¶«Î÷£¬ËäÈ»¿ÚζÓÐËù²»Í¬£¬µ«²»¹ÜÄã´øMMÈ¥Âóµ±ÀÍ»ò¿ÏµÂ»ù£¬Ö»¹ÜÏò·þÎñԱ˵“À´Ëĸö¼¦³á”¾ÍÐÐÁË¡£Âóµ±ÀͺͿϵ»ù¾ÍÊÇÉú²ú¼¦³áµÄFactory
¡¡¡¡¹¤³§Ä£Ê½£º¿Í»§ÀàºÍ¹¤³§Àà·Ö¿ª¡£Ïû·ÑÕßÈκÎʱºòÐèҪijÖÖ²úÆ·£¬Ö»ÐèÏò¹ ......
±¾ÎÄ´Óhttp://www.blogjava.net/breezedancer/archive/2007/07/19/131264.htmlתÔØ
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
//¶ÏµãÐø´ ......
class EnclosingOne {
public class InsideOne {
}
}
public class B {
public static void main(String[] args) {
EnclosingOne eo = new EnclosingOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
}
} ......