I do not know if I fully understand your question, but I think you have a few mistakes in your code. Like declare name of person as static variable, because static variables are often used as variables for the entire class, and if you changed the name, would change the name to the entire class, not for one instance. Also final is wrong, because you cannot set final variable.
I would do something like this:
public class Person { private String name; public Person(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return String.format("Person: %s", this.getName()); } } public class Player extends Person{ public Player(String name) { super(name); } public String toString(){ return String.format("Player: %s", this.getName()); } } public class Match { private Player player_one; private Player player_two; public Match(Player player_one, Player player_two) { this.player_one = player_one; this.player_two = player_two; } public Player getPlayer_one() { return player_one; } public void setPlayer_one(Player player_one) { this.player_one = player_one; } public Player getPlayer_two() { return player_two; } public void setPlayer_two(Player player_two) { this.player_two = player_two; } @Override public String toString() { return String.format("Right now are playing %s VS %s",player_one.getName(), player_two.getName()); } } public class PlayerTest { public static void main(String[] args) { Player peter = new Player("Peter"); Player anna = new Player("Anna"); Match tennisMatch = new Match(peter, anna); System.out.println(tennisMatch.toString()); } }
public static final String NAME = "Peter";in every class? You can just have the field in one class and use it in others.