Dynamic object from either from two class in java
<p>UserCourse and NewReleases are different class with same method. but different output.</p>

<pre><code>final Object userCourses;

    if(mFlag == 11){
            try{
                userCourses = new UserCourses(params[0]);
            }catch(Exception e){
                Log.i(TAG, "Exception: " + e.getMessage());
            }

        }
        else if(mFlag == 44){
            try{
                userCourses = new NewReleases();
            }catch(Exception e){
                Log.i(TAG, "Exception: " + e.getMessage());
            }
        }
</code></pre>

<p>Now, when I call </p>

<pre><code>userCourses.getUserCourses().get(i);
</code></pre>

<p>I get "Add cast to userCourses" error.
Both class has this method.</p>

<p>Is it possible to do this or not? If yes please tell me how.</p>
