Professional Documents
Culture Documents
Design Document
Design Document
of their value without use of a single class for every data type. So generics have been used to achieve this purpose. Any kind of data type can be used since the compile time casting is automatically done.
Design Benefits: 1. Type safety: Since the compile time type casting is done all the data types are guaranteed to be type safe. 2. One Single Class: No need to have different classes for string or int or float. Design details of Function:
Constructor: Initializes the object to the given value. public void Variable(T _value) { this.value = _value; }
public void setValue(T newvalue): Changes the stored value in the object to the provided new value. public void setValue(T newvalue) { this.value = newvalue; }
public T getValue(): Returns the value of the type stored in the object. public T getValue() { return this.value; }