151220InnerClassDemo
来源:互联网 发布:国外优秀搜索引擎 知乎 编辑:程序博客网 时间:2024/06/15 05:53
package java151220;
class InnerClassDemo {
public static void main(String[] args) {
// Outer outer = new Outer();
// outer.method();
// Outer.Inner inner=new Outer().new Inner();
// inner.Function();
// new Outer.Inner().Function();
Outer.Inner.Function();
Outer.method();
}
}
/*
* 内部类的访问规则: 内部类可以直接访问外部类中的成员,包括私有
*
*
*/
class Outer {
private int x = 3;
private static int y = 3;
// void method() {
// // System.out.println(x);
// // Inner inner=new Inner();
// // inner.Function();
// Inner.Function();
// }
static class Inner {
// int x=4;
static void Function() {
// int x=6;
System.out.println("Inner :" + y);
}
}
class Inner2{
void show(){
System.out.println("innner2 show");
}
}
public static void method() {
// Inner.Function();
// new Inner2().show(); No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing instance of type Outer (e.g. x.new A() where x is an instance of Outer).
}
}
class InnerClassDemo {
public static void main(String[] args) {
// Outer outer = new Outer();
// outer.method();
// Outer.Inner inner=new Outer().new Inner();
// inner.Function();
// new Outer.Inner().Function();
Outer.Inner.Function();
Outer.method();
}
}
/*
* 内部类的访问规则: 内部类可以直接访问外部类中的成员,包括私有
*
*
*/
class Outer {
private int x = 3;
private static int y = 3;
// void method() {
// // System.out.println(x);
// // Inner inner=new Inner();
// // inner.Function();
// Inner.Function();
// }
static class Inner {
// int x=4;
static void Function() {
// int x=6;
System.out.println("Inner :" + y);
}
}
class Inner2{
void show(){
System.out.println("innner2 show");
}
}
public static void method() {
// Inner.Function();
// new Inner2().show(); No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing instance of type Outer (e.g. x.new A() where x is an instance of Outer).
}
}
0 0
- 151220InnerClassDemo
- date0408/InnerClassDemo.java
- 内部类学习笔记InnerClassDemo.java
- 151220DuoTaiDemo2
- 151220DuoTaiDemo3
- 151220DuoTaiDemo4
- 151220DBOperate
- 151220InnnerClassTest
- 151220InnerClassDemo2
- 151220InnnerClassDemo3
- 151220ObjectDemo
- 151220DuoTaiDemo多态详解1
- Linux安装WebLogic12c
- LeetCode First Missing Positive
- 解决eclipse和studio无法连接developer.android在线更新的解决方法
- Android屏幕适配全攻略(最权威的官方适配指导)
- centos关闭防火墙
- 151220InnerClassDemo
- C陷阱与C缺陷笔记
- java三大框架原理
- 151220InnnerClassTest
- wordpress禁用REST API/移除wp-json链接的方法
- java spring中对properties属性文件加密及其解密
- 批处理文件中的当前路径获取
- C primer Plus2-2
- 百度地图自定义图标动画