java jls8_GitHub - scmod/jls8
jls8
語言規范里面貌似挺多東西...看下來貌似就是無限的引用其他章節的東西,略跳躍
The null reference can always be assigned or cast to any reference type (§5.2, §5.3,
§5.5)
null可以隨便強轉...
A class method that is declared synchronized (§8.4.3.6) synchronizes on the
monitor associated with the Class object of the class.
synchronized方法相當于普通方法里面加個synchronized(this.getClass())
The Class String
A String object has a constant (unchanging) value.
String literals (§3.10.5) are references to instances of class String
不變的String,"xxx"文字是String的一個實例
At run time, several reference types with the same binary name may be loaded
simultaneously by different class loaders. These types may or may not represent
the same type declaration. Even if two such types do represent the same type
declaration, they are considered distinct.
不同的classLoader加載的同一個class文件也是被認作不同的,==號,instanceof返回false吧..cast就不用說會報錯了..
Object >1 Object[]
Cloneable >1 Object[]
java.io.Serializable >1 Object[]
似乎數組都是可以進行clone,進行序列化的,所以...Cloneable c = new Object[10];
Collections.reverse(List> list)
size < REVERSE_THRESHOLD || list instanceof RandomAccess
這個是看泛型通配符順路發現的....jdk實現倒轉一個集合,如果集合并不是RandomAccess的,那么get需要對調的元素會非常耗費時間,
所以默認定義了個閾值18,超過18并且不能隨機訪問的進行倒轉會直接用迭代器來get需要對調的元素...考慮略充分...
8新增了個ElementType.TYPE_USE,這樣的注解可以@C int @A [] @B [] f;注解在[]前..
具體在9.7.4,從4.11當中那段引用過去的...
并且getDeclaredAnnotations這個方法及類似的方法是獲取不到的,這個方法只能獲取到ElementType = 當前實例類型的注解
比如Field.getDeclaredAnnotations似乎只能獲取到ElementType = ElementType.FIELD的注解數量,
其他的可以通過getAnnotatedType進一步操作來獲取
A variable of type Object[] can hold a reference to an array of any reference type
Object[]只能放any reference type,不包括primitive type
所以上次誰跟我說的在新的jdk里可以支持Integer[] i = new int[10];..坑..
還發現了effectively final的解釋.~匿名內部類引用外部數據只要是effectively final的可以不用將外部數據定義成final
雖然感覺定義不定義沒什么意義,具體看看后面會不會提到
第六章講了些命名的規范,如何讓命名有意義~以及一些可見性的東西,好像不是很有看頭,主要是外部類私有的東西的內部類可見之類的,然后是像
The fully qualified name of the type "array of array of array of array of String" is
"java.lang.String[][][][]".這樣一些定義,?Fully Qualified Names and Canonical Names的差別什么的
順路發現編譯器會把new XXX().method()拆成new XXX();method();這樣調用如果method()是static的話,
雖然一般不會通過實例調用靜態方法
為什么一個靜態內部類不能通過new Outer().new Inner()來創建而只能通過new Outer.Inner():
我想大概是因為內部類實例化需要通過隱藏的構造方法傳入外部類實例,而靜態內部類并沒有any lexically enclosing instances,
更不會提供默認的構造方法用來傳入enclosing instances.
總結
以上是生活随笔為你收集整理的java jls8_GitHub - scmod/jls8的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 科技大公司上万人研究AI,为何比不上Op
- 下一篇: Java布局怎么加图片组件_java