UserCourse and NewReleases are different class with same method. but different output.
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());
}
}
Now, when I call
userCourses.getUserCourses().get(i);
I get “Add cast to userCourses” error.
Both class has this method.
Is it possible to do this or not? If yes please tell me how.
How would you expect this to work,
useCoursesis of the base typeObject– which does not have this method.Learn about
Interfacesand how to use them.