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

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.

主站蜘蛛池模板: 西乡县| 宜兰县| 酉阳| 罗山县| 商丘市| 龙山县| 扶沟县| 桦川县| 墨脱县| 青浦区| 桦甸市| 阆中市| 睢宁县| 巧家县| 太谷县| 忻城县| 北京市| 高邑县| 安陆市| 奎屯市| 横峰县| 革吉县| 乐都县| 多伦县| 泰宁县| 潜山县| 榕江县| 安新县| 屏南县| 雷波县| 雅安市| 洛南县| 衡山县| 轮台县| 张家川| 石家庄市| 新邵县| 沾益县| 汨罗市| 绥宁县| 泽州县|