How to fix r=g compilation issue in Java?
<p>Fr the following generic class, there is a compilation error for the line r=g:
Type mismatch: cannot convert from GenericTest1&lt;Integer&gt; to GenericTest1&lt;Number&gt;
How can it be fixed?</p>

<pre><code>public class GenericTest1&lt;T&gt; {
    private T t;

    public GenericTest1(T t) {
        this.t = t;
    }

    public void set(T t) {
        this.t = t;
    }

    public T get() {
        return t;
    }

    public static void main(String[] args) {
        GenericTest1&lt;Integer&gt; g = new GenericTest1&lt;&gt;(6);
        GenericTest1&lt;Number&gt; r = g; &lt;==here
    }
}
</code></pre>
