I have two classes Class A
and Class B
. I have made a query, say repository.findById
. This query may return output which may be of type A or type B.
Now, class B has all the fields which are in class A and some additional fields.
I know I can write like:
B res = repository.findById;
But writing like this is can be misleading as Class A and B are conceptually very different.
So basically the problem is
? res =repository.findById;
where ?
can be A or B.
How should I solve this problem?
Aucun commentaire:
Enregistrer un commentaire