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

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.

主站蜘蛛池模板: 栖霞市| 迁安市| 邵东县| 县级市| 扬州市| 临沧市| 宜章县| 城市| 鄂温| 南召县| 阜新市| 韶山市| 景泰县| 池州市| 湟源县| 克山县| 宁明县| 广灵县| 永城市| 长垣县| 金沙县| 天祝| 台中市| 肇州县| 调兵山市| 雅江县| 江油市| 克拉玛依市| 喀喇沁旗| 菏泽市| 明溪县| 清河县| 康乐县| 金堂县| 商水县| 翁牛特旗| 什邡市| 宣汉县| 五河县| 竹北市| 顺昌县|