JavaÄÚ²¿ÀࣨInner Class£©Ïê½â
ÖØÐÂÀ´ÈÏʶһÏÂÄÚ²¿ÀàµÄÇø±ð
1
Static member class£¨¾²Ì¬³ÉÔ±Àࣩ
ÀàÉùÃ÷Öаüº¬“static”¹Ø¼ü×ÖµÄÄÚ²¿Àà¡£ÈçÒÔÏÂʾÀý´úÂ룬
Inner1/Inner2/Inner3/Inner4¾ÍÊÇOuterµÄËĸö¾²Ì¬³ÉÔ±Àà¡£¾²Ì¬³ÉÔ±ÀàµÄʹÓ÷½Ê½ÓëÒ»°ã¶¥²ãÀàµÄʹÓ÷½Ê½»ù±¾Ïàͬ¡£
public
class
Outer{
//
just like static method, static member class has public/private/default access privilege levels
//
access privilege level: public
public
static
class
Inner1 {
public
Inner1() {
//
Static member inner class can access static method of outer class
staticMethod();
//
Compile error: static member inner class can not access instance method of outer class
//
instanceMethod();
}
}
//
access privilege level: default
static
class
Inner2 {
}
//
access privilege level: private
private
static
class
Inner3 {
Ïà¹ØÎĵµ£º
Ãô½Ý¿ª·¢µÄÀíÄîÒѾÁ÷ÐÐÁ˺ܳ¤µÄʱ¼ä£¬ÔÚÃô½Ý¿ª·¢ÖеĿª·¢µü´ú½×¶ÎÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÎå¸ö²½Ö裬À´ÓÐЧµÄÌá¸ßÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿¡£
JavaÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÓÉÓÚ¿ª·¢ÈËÔ±µÄ¾Ñé¡¢Java´úÂë±àдϰ¹ß£¬ÒÔ¼°È±·¦Í³Ò»µÄ±ê×¼ºÍ¹ÜÀíÁ÷³Ì£¬ÍùÍùµ¼ÖÂÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿½Ï²î£¬ÄÑÓÚά
»¤£¬ÐèÒª½Ï´óµÄ²âÊÔͶÈëºÍÖÜÆÚµÈÎÊÌâ¡£ÕâЩÎÊÌâÔÚÒ»¸ ......
ÖÚËùÖÜÖª£¬javaµÄÖÐÎÄÎÊÌâÒ»Ö±ÊÇÒ»¸öÀÏ´óÄѵÄÎÊÌ⣬Õâ¸öÏÖÏó¿ÉÒÔÔÚcsdnÖÐjavaÂÛ̳Àï¹ØÓÚÖÐÎÄÂÒÂëµÄÌáÎÊÂʾͿÉÒÔÁ˽⵽£¬ÉõÖÁÈí¼þ¾ÞÈËIBMרÃÅ¿ª±ÙÁËÒ»¸ö½â¾öÖÐÎÄÎÊÌâµÄרÇø£¬×÷Ϊһ¸öË×ÈË£¨Ò»Ö±ÃÎÏëÏ£ÍûÏë½ð¿ÀûÄÇÑù³ÉΪһ¸ö“ðÅÆÌìÉñ”£¬Ö»ÊÇһֱûÓгɹ¦£¬Ò²ÐíÊÇÒòΪÉϵ۲»ÕÕ¹ËÖйú°É£©£¬ÎÒҲΪͬÒâµÄÎÊÌâÀ§ÈÅ£ ......
Ò»£¬ package,importÒýÈëÔÒò£º
package:
ÎÒÃǶ¼ÊìϤ³¬ÊУ¬³¬ÊÐËäÈ»ÅӴ󣬶«Î÷·±¶à£¬µ«È´¹ÜÀíµÄ¾®¾®ÓÐÌõ£¬µ±ÕÒijÑù¶«¶«Ê±£¬ÎÒÃÇÒ²ºÜÈÝÒ×ÕÒ
µ½£¬ËüµÄÒ»¸öÖØÒªµÄÔÒò¾ÍÊDzÉÓÃÁË·ÖÀà·ÅÖûúÖÆ£¬ÎïÆ··ÖÃűðÀà·ÅÖÃÔÚרÃŵÄÇøÓò£¬¼È·½±ã¹ÜÀí£¬ÓÖ·½±ãÑ°ÕÒ
PackageÒ²ÊÇÒ»¸ö·ÖÀà·ÅÖö«¶«µÄÇøÓò£¬²»¹ýËü·Åµ ......
Package µÄÃüÃû
Package µÄÃû×ÖÓ¦¸Ã¶¼ÊÇÓÉÒ»¸öСдµ¥´Ê×é³É¡£
Class µÄÃüÃû
Class µÄÃû×Ö±ØÐëÓÉ´óд×Öĸ¿ªÍ·¶øÆäËû×Öĸ¶¼Ð¡Ð´µÄµ¥´Ê×é³É
Class ±äÁ¿µÄÃüÃû
±äÁ¿µÄÃû×Ö±ØÐëÓÃÒ»¸öСд×Öĸ¿ªÍ·¡£ºóÃæµÄµ¥´ÊÓôóд×Öĸ¿ªÍ·¡£
Static Final&nbs ......
ÐòÑÔ:
Java ÔÚÔËÐÐÒѱàÒëÍê³ÉµÄÀàʱ£¬ÊÇͨ¹ý java ÐéÄâ»úÀ´×°ÔغÍÖ´Ðеģ¬java ÐéÄâ»úͨ¹ý²Ù×÷
ϵͳÃüÁî JAVA_HOME\bin\java ?option À´Æô¶¯£¬-option ΪÐéÄâ»ú²ÎÊý£¬JAVA_HOME ΪJDK
°²×°Â·¾¶£¬Í¨¹ýÕâЩ²ÎÊý¿É¶ÔÐéÄâ»úµÄÔËÐÐ״̬½øÐе÷Õû£¬ÕÆÎÕ²ÎÊýµÄº¬Òå ......