Is there a way to copy only the contents of the superclass into another class of the same type through a subclass instance in Java, without accessing getters and setters one by one?
Example:
public class A {
private Integer id;
private String nome;
//outros
}
public class B extends A {
private String age;
}
I need to do something like:
B objB = new B();
objB.setId(10);
objB.setNome("Jonh Doe");
objB.setAge(21);
A objA = // AQUI COPIAR DE objB apenas o conteúdo da superclasse A