Inner classes in Java, the mystery within.
Inner classes, also called Nested Classes, are nothing but classes that are defined within other classes. The nesting is a relationship between classes, not objects.
Inner classes have clearly two benefits, name control & access control. In Java, this benefit is not as important because Java packages give the name control.
Java inner classes have feature that makes them richer and more useful. An object of an inner class has an implicit reference to the outer class object that instantiated it. Through this pointer, it gains access to any variable of the outer object. Only static inner classes don’t have this pointer. It is actually invisible when we write the code, but compiler takes care of it. Inner classes are actually a phenomenon of the compiler and not the JVM.
Inner classes may be defined with following access modifiers : public, protected, private, or with default package access.
The syntax for inner class is as follows:
[modifiers] class OuterClassName {
code...
[modifiers] class InnerClassName {
code....
}
}
Inner Classes:
Following properties can be noted about Inner classes:
The outer class (the class containing the inner class) can instantiate as many number of inner class objects as it wishes, inside it’s code.
If the inner class is public & the containing class as well, then code in some other unrelated class can as well create an instance of the inner class.
In above case the inner class can be created as follows:
<OuterClassName> outerObj = new <OuterClassName>(arguments);
outerObj.<InnerClassName> innerObj = outerObj.new <InnerClassName>(arguments);
No inner class objects are automatically instantiated with an outer class object.
If the inner class is static, then static inner class can be instantiated without an outer class instance, otherwise, the inner class object must be associated with an instance of the outer class.
Inner class code has free access to
Ïà¹ØÎĵµ£º
/*
ArrayListÊÇ×î³£ÓõÄListʵÏÖÀ࣬ÄÚ²»ÊÇͨ¹ýÊý×éʵÏֵģ¬ËüÔÊÐí¶ÔÔªËØ½øÐпìËÙËæ»ú·ÃÎÊ¡£Êý×éµÄȱµãÊÇÿ¸öÔªËØÖ®¼ä²»Äܺ¬ÓГ¿Õ϶”£¬µ±Êý×é´óС²»Âú×ãʱÐèÒªÔö¼Ó´æ´¢ÄÜÁ¦£¬¾ÍÒª½«ÒÑÓÐÊý×éÊý¾Ý¸´ÖƵ½ÐµĴ洢¿Õ¼äÖС£µ±´ÓArrayListµÄÖмäλÖòåÈë»òÕßɾ³ýÔªËØÊ±£¬ÐèÒª¶ÔÊý×é½øÐи´ÖÆ¡¢Òƶ¯£¬´ú¼Û±È½Ï¸ß¡£Òò ......
java»·¾³Ïµ÷ÓÃVC++±àдµÄ¶¯Ì¬Á´½Ó¿âÎļþ
Ò»£¬¿ª·¢Æ½Ì¨£º
MyEclipse 6.0£¬VC++6.0
¶þ£¬JNI»ù´¡ÖªÊ¶£º
JNI(java native interface)£¬JAVA±¾µØ½Ó¿Úµ÷Óã¬Ä¿µÄÊÇΪÁËJAVA¿ÉÒÔµ÷Óñ¾µØ³ÌÐò¡£
Èý£¬½»»¥¹ý³Ì£º
1£¬½¨Á¢javaÀà¡£ÀýÈ磬½¨Á¢Ò»¸öRSA¼ÓÃܽâÃܵÄÀࣺ
package zkxx.ctais2.client.common;
public class RsaE ......
1£®´Ó×ÜÌ忴ʼþ»úÖÆ
Æäʵʼþ»úÖÆÊÇÒ»ÖÖ´¦ÀíÊÀ½çµÄ·½Ê½ºÍ·½·¨¡£´«Í³µÄ˳Ðò³ÌÐòÉè¼Æ×ÜÊǰ´ÕÕÁ÷³ÌÀ´°²ÅÅËù×öµÄ¹¤×÷£¬¶øÊ¼þ»úÖÆµÄÌØµãÔÚÓÚ£ºµÈ´ý£¬Èç¹ûÓÐÊÂÇé·¢ÉúÔò´¦ÀíÖ®¡£ÕâÑùµÄºÃ´¦ÊÇ˳Ðò³ÌÐòÉè¼ÆÔÚûÓÐÊÂÇé×öµÄʱºòÒ²±ØÐëÑ»·ÔËÐУ¬×öºÁÎÞЧÂʵĿյÄÑ»·¹¤×÷¡£¶øÊ¼þ»úÖÆÔÚûÓÐÊÂÇéµÄʱºòÔò¿ÉÒÔ²»×öÈκÎÊÂÇéµÄµÈ´ý£¬´Ó¶ ......
Ìá¸ßJAVAµÄÐÔÄÜ£¬Ò»°ã¿¼ÂÇÈçϵÄËĸöÖ÷Òª·½Ã棺
£¨1£© ³ÌÐòÉè¼ÆµÄ·½·¨ºÍģʽ
Ò»¸öÁ¼ºÃµÄÉè¼ÆÄÜÌá¸ß³ÌÐòµÄÐÔÄÜ£¬ÕâÒ»µã²»½öÊÊÓÃÓÚJAVA£¬Ò²ÊÊÓÃÒ²Èκεıà³ÌÓïÑÔ¡£ÒòΪËü³ä·ÖÀûÓÃÁ˸÷ÖÖ×ÊÔ´£¬ÈçÄڴ棬CPU,¸ßËÙ»º´æ£¬¶ÔÏó»º³å³Ø¼°¶àỊ̈߳¬´Ó¶øÉè¼Æ³ö¸ßÐÔÄܺͿÉÉìËõÐÔÇ¿µÄϵͳ¡£
µ±È»£¬ÎªÁËÌá¸ß³ÌÐòµÄÐÔÄܶø¸Ä±äÔÀ´µÄÉè¼ÆÊÇ ......
2010-01-16 06:51
¾ÝInternetNews.com±¨µÀ
£¬×÷Ϊ½ñÄêµÄµÚÒ»´Î¸üУ¬Java SE 6 Update 18£¨Ò²³ÆÎª6u18£©²»½öÐÞ¸´Á˳¬¹ý300¸öbug£¨¹»¶àµÄ°¡£©£¬¶øÇÒ¸üÖµµÃ×¢ÒâµÄÊÇ£¬ÌáÉýÁËÐéÄâ»úHotSpotµÄÐÔÄÜ£¬Õ⽫ͬʱÓÐÒæÓÚJavaºÍJavaFX£¨»ùÓÚJVMµÄRIA·½°¸£©Ó¦ÓóÌÐò¡£
´ËÍ⣬Java°²×°Æ÷µÄµ×²ã»úÖÆ±»Ìæ»»£¬¿ÉÓÃÐÔ´ó´óÌá¸ß¡£
jarÎļþ´ ......