Reputation: 1729
I have to work with a JAXB type (named "runtime") that contains the following XSD element:
<xsd:element name="scripts" minOccurs="1" maxOccurs="1">
<xsd:simpleType>
<xsd:list itemType="xsd:string" />
</xsd:simpleType>
</xsd:element>
Thus I have code like:
runtime.getScripts()
Is there as way I can update the script value? The following does not work:
for (String aScript : runtime.getScripts()) {
final String updatedScript = "dummy";
aScript = updatedScript; // ?
}
Thanks.
Upvotes: 0
Views: 144
Reputation: 149037
You could use the set
method on List
to update the values:
Demo
import java.util.*;
public class Demo {
public static void main(String[] args) {
List<String> scripts = new ArrayList<String>();
scripts.add("foo");
scripts.add("bar");
for(int x=0,size=scripts.size(); x<size; x++) {
scripts.set(x, "dummy");
}
for(String script : scripts) {
System.out.println(script);
}
}
}
Output
dummy
dummy
Upvotes: 1