Java passes primitives (ints / floats / strings) to methods by COPYING their VALUE. On the other hand, other OBJECTS are not copied when passed to the method (that is, other objects retain their state and can be changed by an external method).
There is no concept of C style pointers in Java, so you usually don't overwrite an integer value in java methods - rather, you specify integers as a result of the calculation that happens in the method. Or, as a rule, you define objects and use getters and setters in these objects to get / set values.
In your case ... you must either (1) declare the integer that you compute in the method as a global variable, or (2) return the computed value to the calling class and configure in the class that initially declares / accesses the variable of interest.
1) You can either turn the variable "mee" into a static, global variable, and change it anywhere
or
2) You can edit the "moo" method to RETURN an integer, and set the mee method to this return value.
source share