Why are generics needed when we can do casting to Object class? : <p>We have generics in java using which we can generalize a class.
I know that Object class is the parent class of every class.</p>

<p>When I can typecast to and from Object then why generics are needed?</p>

<pre><code>class Response&lt;T&gt;{
    T data;
}
</code></pre>

<pre><code>class Response{
    Object data;
}
</code></pre>

<p>Both of the above code snippets will work the same way.</p>
