Memo Solution
Soldier alpha;
Soldier bravo;
alpha = new Soldier(); //Create alpha
alpha.age = 21; //Assign 21 to the variable alpha.age
bravo = alpha //Assign alpha reference to bravo. bravo is now alpha not the copy.
bravo.age = 42 //Assign 42 to the variable bravo.age.
System.out.print("Alpha is" + alpha.age + "years old.");
Alpha is 42 years old.
I have 2 fragments. I would like them to use the same variable. It means if one fragment changes the variable I don't need to send it to the other to get it.
I have developed in C and for that I just need to send the variable's memory address.
What is the best way to do that in Java/Android ?
Thanks in advance :)