Essentially I'm trying to do something that is stated here Changing variables in multiple Python instances but in java.
I want to reset a variable in all instances of a certain class so something like:
public class NewClass{
int variable = 1;
}
then:
NewClass one = new NewClass();
NewClass two = new NewClass();
NewClass three = new NewClass();
Newclass.variable = 2;
System.out.println(one.variable);
System.out.println(two.variable);
System.out.println(three.variable);
output would be:
2
2
2
is there a way to do that?
variablealways be the same for each instance? If yes then you can make that variablestaticviastatic int variable = 1;which would mean it doesn't belong to instances but to class.static. But this seems pretty much like an XY problem to me. What are you actually trying to do?