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();
}
}
µ÷ÓÃÒ»¸ö¾²Ì¬·½·¨¾ÍÊÇ“ÀàÃû.·½·¨Ãû”,¾²Ì¬·½·¨µÄʹÓúܼòµ¥ÈçÉÏËùʾ¡£Ò»°ãÀ´Ëµ£¬¾²Ì¬·½·¨³£³
Ïà¹ØÎĵµ£º
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* @author dengshaohua
*/
public class ReadPhone {
/**
* ¶ÁÈ¡Êý¾Ý
*/
public void ReadData(){
try {
FileReader read = new File ......
µÚÒ»Õ ¸ÅÊö
°æȨÉùÃ÷
´ËÎĵµÓÉÍõ½¡Ðñ(http://www.wangjianxu.com ginger547@gmail.com )¸ºÔðÕûÀí×ܽᣬ²¢¶Ô¸ÃÎĵµ±£ÓÐÓÐÏÞÔðÈÎȨÀû£¬´ËÎĵµÖ»ÄÜÓÃÓÚѧϰÒÔ¼°½Ìѧ£¬ÇëÎðÓÃ×÷ÉÌÒµÓÃ;£¬Òò´Ë¶ø
²úÉúµÄ·¨ÂÉÎÊÌ⣬±¾ÈËÒ»¸Å²»¸ºÔð¡£ ±¾ ......
±¾ÎÄ´Ó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;
//¶ÏµãÐø´ ......
ÓÃspyºÍmemcached for javaÁ½ÖÖ·½Ê½¶Ômemcache½øÐвÙ×÷
Ò»¡¢spy
package com.test.memcache;
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
import net.spy.memcached.MemcachedClient;
/**
* ±¾ÀàÓõİüÊÇmemcached-2.4.1.jar
* ÏÂÔصØÖ·£º http://code.googl ......
class EnclosingOne {
public class InsideOne {
}
}
public class B {
public static void main(String[] args) {
EnclosingOne eo = new EnclosingOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
}
} ......