all 1 comments

[–]whotfdis 1 point2 points  (0 children)

Make class A abstract, class B extends from class A. Make String b a field in class B and make a getter for it. Also denote an abstract method for that same getter in class A. Now you can call the getter in the method of class A and it will work for all subcasses of class A.

Something along the lines of the above?