
上QQ阅读APP看书,第一时间看更新
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.