Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Link for : <a href="http://jaxb.java.net/tutorial/section_2_2_7-Defining-a-List-of-Integers.html" rel="noreferrer">No setter for list</a></p> <blockquote> <p>The code in the getter method ensures that the List is created. There is no corresponding <strong>setter</strong> which means that all additions or deletions of list elements have to be made on the <strong>"live"</strong> list.</p> </blockquote> <p>As the quote says that there is no setter as when you use the getter method it insures that a new instance of the list is initialized if not present.</p> <p>And after that when you have to add or remove anything you will have to use </p> <pre><code>getElement3().add(Type); </code></pre> <p><strong>UPDATE</strong> : Difference in marshalling for <code>null</code> and empty list</p> <p>Example where list is <code>null</code></p> <pre><code>@XmlRootElement(name = "list-demo") public class ListDemo { @XmlElementWrapper(name = "list") @XmlElement(name = "list-item") private List&lt;String&gt; list; } </code></pre> <p>OUTPUT will be </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;list-demo/&gt; </code></pre> <p>Example where list is <strong>empty</strong></p> <pre><code>@XmlRootElement(name = "list-demo") public class ListDemo { @XmlElementWrapper(name = "list") @XmlElement(name = "list-item") private List&lt;String&gt; list = new ArrayList&lt;String&gt;(); } </code></pre> <p>OUTPUT will be:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;list-demo&gt; &lt;list/&gt; &lt;/list-demo&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload