package com.oop;
import com.oop.demo10.Outer;
public class Application {
public static void main(String[] args) {
//外部 new
Outer outer = new Outer();
//通过外部类来实例化内部类
//Outer.Inner inner = outer.new Inner();
//inner.in();
}
}
/*
package com.oop.demo10;
public class Test {
public static void main(String[] args) {
//Apple apple=new Apple(); 这是常规方法
//没有名字初始化类,不用将实例保存到变量中
new Apple().eat();
new UserService(){
@Override
public void hello() {
}
};
}
}
class Apple{
public void eat(){
System.out.println("1");
}
}
interface UserService{
void hello();
}
*/
/*
package com.oop.demo10;
public class Outer {
private int id=10 ;
public void out(){
System.out.println("这是外部类的方法");
}
public static class Inner{
public void in(){
System.out.println("这是内部类的方法");
}
//局部内部类
public void method(){
class Innter{
}
}
}
//一个Java文件中,可以有多个class,但只能有一个public class
class A{
}
// public class Inner{
// public void in(){
// System.out.println("这是内部类的方法");
//
// }
// public void getId(){
// System.out.println(id);
// }
// }
}
*/