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

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.

主站蜘蛛池模板: 桦甸市| 武陟县| 永修县| 博野县| 元阳县| 秦安县| 托克托县| 天台县| 长汀县| 榆树市| 高阳县| 轮台县| 西乡县| 东兰县| 福鼎市| 泊头市| 乐山市| 恩施市| 钟山县| 安泽县| 宁蒗| 富民县| 合肥市| 托里县| 澄江县| 资源县| 婺源县| 丹凤县| 平罗县| 湖南省| 昌黎县| 那坡县| 龙泉市| 南皮县| 德兴市| 福贡县| 同江市| 灵宝市| 玉溪市| 兰州市| 卢龙县|