今天的一点收获

  1. /** 
  2.  * 以下程序编译错误 
  3.  * Java类的成员变量会被自动初始化,但局部变量不会被自动初始化 
  4.  */ 
  5. public class Test { 
  6.     public static void main(String[] args){ 
  7.         int x; 
  8.         System.out.println(x); //The local variable x may not have been initialized 
  9.     } 
  10. /** 
  11.  * 以下定义正确与否
    */ 
  12. abstract public class TestProtected {}//Right! 
  13. final public class Test4{}//Right! 
  14.  
  15. //protected 不能用来定义类或接口 
  16. protected class Test{}//Error! 
  17.  
  18. //非嵌套类和接口都不能使用static定义 
  19. public static interface Test{}//Error! 
  20. static class Test{} //Error!  
  21. //注:只有在内部类时可以定义静态内部类