I have created 2 classes as follows…
public class A extends JFrame {
public String x = "abcdefg";
}
public class B extends JFrame {
public String y;
}
Both of these classes extend JFrame. I am wondering whether there is a way that the String y in Class B can inherit the value of String x in Class A? I want it such that updating either x or y will also update the other String.
Is there a way that I can make these Strings common to the 2 classes?
Just make class B extend A.
But TBH, we all think it’s a terrible idea to have public fields!