interface Inter
{
public void method();
}
class Test
{
static Inter function()
{
return new Inter()
{
public void method()
{
System.out.println("method run");
}
};
}
}
public class InnerClassTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
//test有个静态方法function,而且返回值为一个对象,
//只要对象 才能调用method方法
Test.function().method();
}
{
public void method();
}
class Test
{
static Inter function()
{
return new Inter()
{
public void method()
{
System.out.println("method run");
}
};
}
}
public class InnerClassTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
//test有个静态方法function,而且返回值为一个对象,
//只要对象 才能调用method方法
Test.function().method();
}
}
运行结果: