why do some people make a new reference in method to a field variable?
public class Foo {
int mFoo[] = {1, 2, 3};
void method() {
int foo[] = mFoo; // WHY not just use mFoo?
print(foo[0]); // WHY not just use mFoo?
}
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It can be a good idea if for example, at another place of your code, you change the value of mFoo. Especially in a multithreaded context, you would want to ensure you’re still working on the right data.