EDIT : The linked duplicate DOES NOT answer this question as it is about HOW it is accessible. But my question is when should such a design be used or any examples of such a design.
NOTE : Anyone looking for an answer to this question can scroll down in the comment section to see Thomas's comments in the end related to java.lang.CharacterData.
Some of the questions with a similar title actually discuss the usage of static variables with the same name in child and parent. example: Java | static vars in parent and child class | accessing the child var value from parent class
But my question is regarding the purpose of accessing child's static field in parent class.
class Child extends Parent {
static String someString = "test";
}
class Parent {
void someMethod() {
System.out.println(Child.someString);
}
}
Isn't this a bad design? Ideally, if someString is required in Parent, then it should be a field in Parent instead of Child.
Are there any use-cases/examples when this approach could be used?