Java Inner class && nested class
摘要:Java中,Inner Class(不被 static修饰)可以访问outer class 的所有成员(包括私有成员),同时,内部类的创建必须经由外部类的实例!nested class 有static修饰,仅能访问outer class 的 static成员
阅读全文
Java 嵌套作用域
摘要:在C/C++中,当一个块处于另一个块作用域内的时候,内层定义的变量会把外层的变量隐藏,遵循所谓的就近原则。在Java中,在内层定义与外层同名的变量是禁止的!如下:int i = 0;for(int i = 0; i < 20; i++){//do Something}这样的代码在C/C++中是可以的...
阅读全文
Java中的blank final
摘要:Java allows the creation of blank finals, which are fields that are declared as final but are not given an initialization value.In all case, the blank...
阅读全文
Java中的接口与抽象类
摘要:抽象类很简单,就是多了个abstract关键字,可以有(也可以没有)只声明不定义的方法。不能实例化该类。接口比较特殊:无论你加不加public,接口中声明的方法都是public的,还有无论你加不加static final,接口中的成员都由这两个关键字修饰。Fields defined in inte...
阅读全文