In your Server
constructor, send the instance of your History
object (e.g new Server (history)
, and then you can invoke, history.addToHistoryArea
, other option would be have a setter
method which sets
an instance of history
to an instance variable, and then just call the addToHistoryArea
method
public class Server{
private History history;
public Server(History history){
this.history = history;
}
public void someMethod(){
this.history.addToHistoryArea();
}
}
Another way
public class Server{
private History history;
public void setHistory(History history){
this.history = history;
}
public void someMethod(){
this.history.addToHistoryArea();
}
}