In Java, I have two classes that each take values from a Singleton class but it seems to be changing values in the Singleton and I would just like a local copy. This is a shortened version of whats happening in my classes.
method.getName() should return "Abbey", as thats how it was created earlier
public class MethodFragment1 extends Fragment {
private Method method = MethodLab.get(getActivity()).getMethod();
method.setName("Test");
}
public class MethodFragment2 extends Fragment {
private Method method = MethodLab.get(getActivity()).getMethod();
System.out.println(method.getName());
}
The output is "Test"
Do both classes not get a local copy of the Method
from the Singleton
class MethodLab
and if not how do I get a local copy?