|NO.Z.00054|——————————|BigDataEnd|——|Java&集合类库.V02|——|Java.v02|泛型机制.v02|底层原理|

一、泛型机制的底层原理
### --- 底层原理

——>        泛型的本质就是参数化类型,也就是让数据类型作为参数传递,
——>        其中E相当于形式参数负责占位,而使用集合时<>中的数据类型相当于实际参数,
——>        用于给形式参数E进行初始化,从而使得集合中所有的E被实际参数替换,
——>        由于实际参数可以传递各种各样广泛的数据类型,因此得名为泛型。
~~~     # 如:

——>            //其中i叫做形式参数,负责占位            其中E叫做形式参数,负责占位
——>            //int i = 10;                                         E = String;
——>            //int i = 20;                                         E = Integer;
——>            public static void show(int i) {            public interface List {
——>            ...                                                          ...
——>            }                                                           }
——>            //其中10叫做实际参数,负责给形式参数初始化             //其中String叫做实际参数
——>            show(10);                                                                     List lt1 = ...;
——>            show(20);                                                                     List lt2 = ...;

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on 2022-04-04 15:02  yanqi_vip  阅读(28)  评论(0)    收藏  举报

导航