samedi 14 janvier 2017

Cast Object[] to another type

I have class A and class B, where class B requires only 5 of 10 properties from A.

So i have something like,

A[] objArray = populateResponse();

And to cast it into B , i do something like

for (A : objArray ){ // getters here and push it to B obj array manually }

Any other suggestions to do it in a better way since A has many fields and size of the array can grow large ?

Thanks in advance !





Aucun commentaire:

Enregistrer un commentaire