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

Working with different data types

Now, let's put a <T> symbol after where it says public class GenericsClass, as follows:

public class GenericsClass<T>

This means that this single class can work equally well with several different data types. Next, enter the following beneath the open curly brace under the preceding line:

private T[] vals;

Enter the following comment directly above this line:

//generic array instance variable

In other words, this will operate equally well on doubles, decimals, integers, and so on.

主站蜘蛛池模板: 东乌珠穆沁旗| 旌德县| 桓台县| 丹棱县| 东宁县| 卓资县| 于田县| 安康市| 阿拉善右旗| 介休市| 茌平县| 紫云| 昌邑市| 宣化县| 贵溪市| 孟连| 开封县| 澄迈县| 华蓥市| 合作市| 滦平县| 石家庄市| 屏南县| 扶风县| 贺兰县| 政和县| 舒兰市| 水城县| 宝丰县| 泗洪县| 马关县| 封开县| 马公市| 分宜县| 灵台县| 枞阳县| 武穴市| 普安县| 阳东县| 鲜城| 连山|