传递原始数据类型参数
Primitive arguments, such as an int or a double, are passed into
methods by value. This means that any changes to the values of the
parameters exist only within the scope of the method. When the method
returns, the parameters are gone and any changes to them are lost.
传递参考数据类型参数
Reference data type parameters, such as objects, are also passed into
methods by value. This means that when the method returns, the
passed-in reference still references the same object as before.
However, the values of the object’s fields can be changed in the
method, if they have the proper access level.
要获得您期望的行为,您需要返回一个值并将其分配给原始变量.
mee = Moo.moo(mee);
在你的方法中:
public static int moo(int mee)
{
// some processing
mee += 76547545;
return mee;
}