I have following two classes
public abstract class A {
public String p1;
public String p2;
// Includes getters/setters
}
public class B extends A {
public String p3;
public String p4;
// Some implementation to populate base class attributes
// Includes getters/setters
}
public static void main(String[] args) {
// Initializing and populating parameters for B
System.out.println(B.getP1());
System.out.println(B.getP2());
}
How can print all the elements of the base class B without invoking individual getters for the attributes in main. Since there is a possibility that in future class A will have additional attribute that will require using getter method again in main for that attribute. All I want is to print all the attributes from the Base class only.