java内部类
public class Outer {
private int id= 10 ;
public void out ( ) {
System . out. println ( "这是外部类的方法!" ) ;
}
public void method ( ) {
class Interior {
}
}
public class Inner {
public void in ( ) {
System . out. println ( "这是内部类的方法!" ) ;
}
public void getId ( ) {
System . out. println ( id) ;
}
public void getMethod ( ) {
out ( ) ;
}
}
}
class A {
}
public class Application {
public static void main ( String [ ] args) {
Outer outer = new Outer ( ) ;
Outer. Inner inner = outer. new Inner ( ) ;
inner. in ( ) ;
inner. getId ( ) ;
inner. getMethod ( ) ;
}
}
public class Test {
public static class In {
public static void main ( String [ ] args) {
}
}
public static void main ( String [ ] args) {
new app ( ) . eat ( ) ;
new UserService ( ) {
@Override
public void hello ( ) {
}
} ;
}
}
class app{
public void eat ( ) {
System . out. println ( "1" ) ;
}
}
interface UserService {
void hello ( ) ;
}