lundi 24 août 2020

Convert object from one class to another in java [closed]

I have 2 custom classes A and B. Now I have an object of A let say 'a' and have to convert it to B class.

Now I have 2 approach

  • First is I write a transform Util which has a static method for conversion.
  • The second approach is to write that logic in class A with a method convertToB()

Which one is more accurate. Please suggest.

Aucun commentaire:

Enregistrer un commentaire