Then I have an ArrayList in Java and what I am doing is creating a new list with updated values. But I want to put those new values in the original ArrayList. This is important because I am passing the original Erlist reference to an object that I do not have access to yet, but I need to keep its contents up to date. Is Java a way to copy content in the current context? I hope this makes sense.
In addition, I did not want to clear the original protection and then through it the new material had to leave the loop through pushing it.
I need to do something like this:
Arrerest A; ArrayList * b = a; // Pass B (Indicator) Some ArrayList c; * B = c; I hope that I think that (cf.) C ++ code is correct or I'll be very stupid = P
I can see how I'm clear I'm not, it's complicated (this is in Android so it's in two activities) Let me see if I can get my point better.
Class1 {ArrayList a; Method1 () {a = Class2.getA (); Method_that_uses_a (a); }} Class 2 {Aare list getA () {ArrayList a = New ArrayList a = getDataFromWebsite (); Return; }
Method 1 of class 1 is called periodically from the second part of the code. But the context of my stay is the same, but the content needs to be converted to new material.
I think your question is unclear, what do you mean by this
"And what I am doing is making a new list with updated values, but I want to keep those new values in the original Array, because I am passing the original Aralyst reference of an object whose now my Do not have access, but I need to keep its content up to date. What is the method to make a copy of the material in the current context? I hope that makes sense. "
When you do
list = a new ArrayList List b = a You have an ArrayList object, and two references to the object, A and B.
Also keep in mind that there is an addAll method that you can use to add members of a collection to another collection. Note that if I believe addAll does not make a deep copy, so if you use it then both lists have copies of the same reference, so if the A1, A2, A3, And you are in B.Adl (A), B, then now the reference to those objects, which indicates a1 ... a3 ...
Comments
Post a Comment