@@ -274,15 +274,15 @@ System.out.println(list);
274274``` java
275275// 此处T可以随便写为任意标识,常见的如T、E、K、V等形式的参数常用于表示泛型
276276// 在实例化泛型类时,必须指定T的具体类型
277- public class Generic <T>{
277+ public class Generic <T> {
278278
279279 private T key;
280280
281281 public Generic (T key ) {
282282 this . key = key;
283283 }
284284
285- public T getKey (){
285+ public T getKey () {
286286 return key;
287287 }
288288}
@@ -316,7 +316,7 @@ class GeneratorImpl<T> implements Generator<T>{
316316实现泛型接口,指定类型:
317317
318318``` java
319- class GeneratorImpl <T> implements Generator<String > {
319+ class GeneratorImpl implements Generator<String > {
320320 @Override
321321 public String method () {
322322 return " hello" ;
@@ -327,13 +327,12 @@ class GeneratorImpl<T> implements Generator<String>{
327327** 3.泛型方法** :
328328
329329``` java
330- public static < E > void printArray( E [] inputArray )
331- {
332- for ( E element : inputArray ){
333- System . out. printf( " %s " , element );
334- }
335- System . out. println();
330+ public static < E > void printArray(E [] inputArray) {
331+ for (E element : inputArray) {
332+ System . out. printf(" %s " , element);
336333 }
334+ System . out. println();
335+ }
337336```
338337
339338使用:
@@ -342,8 +341,8 @@ class GeneratorImpl<T> implements Generator<String>{
342341// 创建不同类型数组: Integer, Double 和 Character
343342Integer [] intArray = { 1 , 2 , 3 };
344343String [] stringArray = { " Hello" , " World" };
345- printArray( intArray );
346- printArray( stringArray );
344+ printArray(intArray);
345+ printArray(stringArray);
347346```
348347
349348** 常用的通配符为: T,E,K,V,?**
@@ -457,7 +456,7 @@ public native int hashCode();
457456
458457在这里解释一位小伙伴的问题。以下内容摘自《Head Fisrt Java》。
459458
460- 因为 ` hashCode() ` 所使用的杂凑算法也许刚好会让多个对象传回相同的杂凑值。越糟糕的杂凑算法越容易碰撞 ,但这也与数据值域分布的特性有关(所谓碰撞也就是指的是不同的对象得到相同的 ` hashCode ` 。
459+ 因为 ` hashCode() ` 所使用的哈希算法也许刚好会让多个对象传回相同的哈希值。越糟糕的哈希算法越容易碰撞 ,但这也与数据值域分布的特性有关(所谓碰撞也就是指的是不同的对象得到相同的 ` hashCode ` 。
461460
462461我们刚刚也提到了 ` HashSet ` ,如果 ` HashSet ` 在对比的时候,同样的 hashcode 有多个对象,它会使用 ` equals() ` 来判断是否真的相同。也就是说 ` hashcode ` 只是用来缩小查找成本。
463462
@@ -750,7 +749,7 @@ public void f5(int a) {
750749
751750首先,我们回顾一下在程序设计语言中有关将参数传递给方法(或函数)的一些专业术语。
752751
753- ** 按值调用(call by value)** 表示方法接收的是调用者提供的值,** 按引用调用(call by reference)** 表示方法接收的是调用者提供的变量地址。一个方法可以修改传递引用所对应的变量值,而不能修改传递值调用所对应的变量值。它用来描述各种程序设计语言(不只是 Java) 中方法参数传递方式。
752+ ** 按值调用(call by value)** 表示方法接收的是调用者提供的值,** 按引用调用(call by reference)** 表示方法接收的是调用者提供的变量地址。一个方法可以修改传递引用所对应的变量值,而不能修改传递值调用所对应的变量值。它用来描述各种程序设计语言(不只是 Java) 中方法参数传递方式。
754753
755754** Java 程序设计语言总是采用按值调用。也就是说,方法得到的是所有参数值的一个拷贝,也就是说,方法不能修改传递给它的任何参数变量的内容。**
756755
@@ -1324,7 +1323,7 @@ try (BufferedInputStream bin = new BufferedInputStream(new FileInputStream(new F
13241323 }
13251324```
13261325
1327- ## I\ O 流
1326+ ## I/ O 流
13281327
13291328### 什么是序列化?什么是反序列化?
13301329
@@ -1349,7 +1348,7 @@ try (BufferedInputStream bin = new BufferedInputStream(new FileInputStream(new F
13491348
13501349### Java 序列化中如果有些字段不想进行序列化,怎么办?
13511350
1352- ` 对于不想进行序列化的变量,使用 ` transient` 关键字修饰。 `
1351+ 对于不想进行序列化的变量,使用` transient ` 关键字修饰。`
13531352
13541353` transient ` 关键字的作用是:阻止实例中那些用此关键字修饰的的变量序列化;当对象被反序列化时,被 ` transient ` 修饰的变量值不会被持久化和恢复。` transient ` 只能修饰变量,不能修饰类和方法。
13551354
@@ -1399,4 +1398,4 @@ Java Io 流共涉及 40 多个类,这些类看上去很杂乱,但实际上
13991398
14001399- https://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre
14011400- https://www.educba.com/oracle-vs-openjdk/
1402- - https://stackoverflow.com/questions/22358071/differences-between-oracle-jdk-and-openjdk?answertab=active#tab-top## 基础概念与常识
1401+ - https://stackoverflow.com/questions/22358071/differences-between-oracle-jdk-and-openjdk 基础概念与常识
0 commit comments