- 1
- 0
- 约4.34千字
- 约 6页
- 2016-12-03 发布于河南
- 举报
第4章 内部类(学生版)
成员内部类
(1)可以访问直接外部类的成员;包括私有;持有外部类的引用;
(2)外部类要访问内部类必须建立内部类对象;
(3)直接内部类中的成员,Outer.Inner in=new Outer().new Inner();(4)外部类和内部类和成员方法内有相同的成员;class Outer
{
private int x = 3;
class Inner//内部类
{
//int x = 4;
void function()
{
//int x = 6;
System.out.println(innner :+Outer.this.x);
}
}
/**/
void method()
{
Inner in = new Inner();
in.function();
}
}
class InnerClassDemo
{
public static void main(String[] args)
{
Outer out = new Outer();
out.method();
//直接访问内部类中的成员。
// Outer.Inner in = new Outer().new Inner();
// in.function();
}
}
class OuterStatic{
sta
您可能关注的文档
最近下载
- 中国铁路兰州局招聘考试真题2024.docx VIP
- 沙盘模拟攻防系统sandbox-安氏领信.pptx VIP
- 2025山东航空笔试题目及答案.doc VIP
- 风险分级管控清单(白酒制造行业).docx VIP
- 17 壶口瀑布 (八年级下册语文).pdf VIP
- 登革热疫情标本采集及实验室检测.pptx VIP
- 2025年4月26日山东省青岛市市属事业单位遴选笔试真题及解析.docx VIP
- 人教版(2019) 选择性必修第一册 Unit 2 Looking into the Future Reading and Thinking课件(共21张).pptx VIP
- TSG 92-2026 承压类特种设备安全附件安全技术规程.doc VIP
- 社会救助档案建设方案及规范(1).pdf VIP
原创力文档

文档评论(0)