文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Java类、接口定义相关

Java类、接口定义相关

时间:2010-10-18  来源:hjhnju

今天的一点收获

  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. //注:只有在内部类时可以定义静态内部类 

 

排行榜 更多 +
侏罗纪狩猎

侏罗纪狩猎

飞行射击 下载
射击瓶子

射击瓶子

飞行射击 下载
水上乐园滑行大作战最新版

水上乐园滑行大作战最新版

休闲益智 下载