I am trying to create a system where one variable can be changed from different classes. The code that I am trying to create is this:
Server:
public class Server(){
public int number = 0;
}
Client:
public class Client extends Server(){
public void run (){
number++;
}
}
Business:
public class Business(){
public void run(){
number++;
}
}
I have another class which instantiates the Client and Business class. The result when I print out the number from a different class is still 0, I am trying to understand the concept of how could the same variable be manipulated from different classes. Do I have to even extend classes, is there some other approach?