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
相关文档:
Java json lib
根据http://www.javaeye.com/topic/561368谈到的一个jackson的json序列化工具性能比json-lib等要好
无论是在低并发还是高并发的情况下,时间性能上,jackson使用重用ObjectMapper方式大大优于使用json-lib方式,甚于jackson使用非重用ObjectMapper方式也略优于json-lib方式。另外也可以看出,jackson在重用 ......
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 ......
来CSDN也有一年时间了,一直没有在自己的空间里发表一点东西。
前几天,我朋友想和我一起搞个东西,需要用到java,我没有一点java基础。没办法,只能够从头开始了学习。
从图书馆抱回了两本书《java2入门 进阶与应用实例》和《java me 实用详解》。由于有C和C++的基础,初略看了一下书,对于书中的内容基本上还是能够理解 ......
1、java是跨平台的,是一门解释性语言,一条一条地执行,解释器就是jvm,所以可以跨平台;
C/C++是编译性语言,所有编译完后再执行,跨平台的时候需要重新编译一次,以适应新的平台。
2、向上转型,继承 白马非马
父类对象转化为子类必须强制(SonClass)fatherClass
子类当 ......