今天的一點收穫ide
- /**
- * 如下程序編譯錯誤
- * Java類的成員變量會被自動初始化,但局部變量不會被自動初始化
- */
- public class Test {
- public static void main(String[] args){
- int x;
- System.out.println(x); //The local variable x may not have been initialized
- }
- }
- /**
- * 如下定義正確與否
*/- abstract public class TestProtected {}//Right!
- final public class Test4{}//Right!
- //protected 不能用來定義類或接口
- protected class Test{}//Error!
- //非嵌套類和接口都不能使用static定義
- public static interface Test{}//Error!
- static class Test{} //Error!
- //注:只有在內部類時能夠定義靜態內部類