package com.hspedu.innerclass_;
// 外部类(外部其他类)
public class Course412 {
public static void main(String[] args) {
// 内部类(重要)
/*
* 类的五大成员:属性、方法、构造器、代码块、内部类
*
* 内部类的分类:4种
* 1、定义在外部类的局部位置上:
* (1)局部内部类(有类名),(2)匿名内部类(没有类名,重点!)
* 2、定义在外部类的成员位置上(也就是和属性和方法的位置)
* (3)成员内部类(没有static修饰),(4)静态内部类(使用static修饰)
* */
}
}
// 外部类
class Outer {
// 属性
private int n1 = 100;
// 方法
public void m1() {
System.out.println("m1");
}
// 代码块
{
System.out.println("code block");
}
// 构造器
public Outer(int n1) {
this.n1 = n1;
}
// 内部类
class Inner {
}
}