static inner class
来源:互联网 发布:淘宝购物少件拒收 编辑:程序博客网 时间:2024/06/09 20:56
Consider the following Java code fragment:
public class AThis fragment defines the class A which contains an static inner class B.
{
int y;
public static class B
{
int x;
void f () {}
}
}
A static inner class behaves like any ``outer'' class. It may contain methods and fields, and it may be instantiated like this:
A.B object = new A.B ();This statement creates an new instance of the inner class B. Given such an instance, we can invoke the f method in the usual way:
object.f();
Note, it is not necessarily the case that an instance of the outer class A exists even when we have created an instance of the inner class. Similarly, instantiating the outer class A does not create any instances of the inner class B.
The methods of a static inner class may access all the members (fields or methods) of the inner class but they can access only static members (fields or methods) of the outer class. Thus, f can access the field x, but it cannot access the field y.
- static inner class
- non-static inner class
- Inner class 的 static
- static class(inner class中 )
- inner class, static nested class
- Proguard keep static Inner Class
- Static Nested Class 和 Inner Class区别
- Static Nested Class 和 Inner Class区别
- 静态内部类(Static Inner Class)
- 静态内部类(Static Inner Class)
- static inner class和非static inner class的实例化问题
- Static Nested Class 和 Inner Class的不同
- static nested class 与 inner class 的不同?
- Inner Class和Static Nested Class的区别
- Java中Static Nested Class 和 Inner Class的不同
- Static Nested Class 和 Inner Class ---学习笔记
- Static Nested Class 和 Inner Class的不同
- Static Nested Class 和 Inner Class的不同
- 十句保你职场不败的名
- 自己仍然是一个菜鸟
- C++中extern “C”含义深层探索
- 使用iText输出PDF文件
- 我过去的六年
- static inner class
- 我最喜爱的十大开发工具
- 什么是好的设计
- 实现图片多变化的显像效果代码
- HP-UNIX命令集合
- C#在Windows 2000 和2003中运行出现的错误:"试图运行项目进出错:未能加载文件或程序集..."
- weblogic学习笔记(-)
- Thinking in C++ (1-9) C++为什么会成功
- 零起点学VB做外挂(五)