- public class Example99 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Test.function().method();
- }
- }
- interface Inter
- {
- void method();
- }
-
- class Test {
- public static Inter function(){
- return new Inter(){
- public void method(){
- System.out.println(4);
- }
- };
- }
- }
复制代码 为何当public static Inter function()中的Inter换为void时并把return取消,Test.function().method();会报错 |
|