package com.inba.maya.JiHe; public class NeiBuLei { public class T1{ } static class T2{private String name; public void l(){} static void k(){} } interface T3{ public void yi(); public void er(); } abstract class T4{ } }
package com.inba.maya.JiHe; public class CeShi { public static void main(String[] args) { //在实例化,实例成员类时需先实例化文件类再点new内部类 NeiBuLei.T1 t1=new NeiBuLei().new T1(); //在实例化,静态成员类时直接可以用类名调用其静态类然后new出来 NeiBuLei.T2 t2=new NeiBuLei.T2(); //实例化接口时需要一个大括号 NeiBuLei.T3 t3=new NeiBuLei.T3() { @Override public void yi() { System.out.println("无名内部类"); } @Override public void er() { // TODO 自动生成的方法存根 } }; t3.yi(); } }