官术网_书友最值得收藏!

How it works...

At the heart of generics lies the ability to reuse a single class or method. It allows developers to essentially not repeat similar code throughout your code base. This conforms well to the Don't Repeat Yourself (DRY) principle. This design principle states that a specific bit of logic should be represented in code only once.

Using generic classes, for example, also allows developers to create a class that is type safe when compiling. Type safe basically means that the developer can be assured of the type of the object and can use the class in a specific way without experiencing any unexpected behavior. Therefore, the compiler takes over the burden of type safety.

Generics also allow developers to write less code, because code can be reused and less code also performs better.

主站蜘蛛池模板: 宜良县| 兰溪市| 小金县| 建瓯市| 容城县| 定结县| 铜梁县| 静安区| 漯河市| 西充县| 崇文区| 金湖县| 贵州省| 伊通| 大石桥市| 休宁县| 年辖:市辖区| 建阳市| 绍兴市| 镇沅| 长治市| 青浦区| 白城市| 汾阳市| 北宁市| 巢湖市| 宁强县| 那曲县| 临夏县| 永州市| 铜陵市| 宁海县| 肃宁县| 南澳县| 板桥市| 阳西县| 临漳县| 马龙县| 西盟| 长岭县| 桐柏县|