title: @XmlElementRefs & @XmlElementRef annotations in Java
body: <p>Can some please explain to me what do</p>
  
  <pre><code>@XmlElementRefs
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@XmlElementRef
  </code></pre>
  
  <p>annotations mean in Java and what is their use..</p>
  
  <blockquote>
    <p><b>EDIT:</b>
    @skaffman</p>
  </blockquote>
  
  <p>okay, suppose I have one such collection</p>
  
  <pre><code>@XmlElementRefs({
      @XmlElementRef(name="ElementA", type=ClassA),
      @XmlElementRef(name="ElementB", type=ClassB) }
  )
  
  List&lt;Object&gt; items;
  </code></pre>
  
  <p>Now how do I access every individual element of this list? Is the following code correct? </p>
  
  <pre><code>for (int j = 0; j &lt; items.size(); ++j) {
      if (items.get(i).getClass().equals(ClassA)) {
          // perform ClassA specific processing:
      } else if (items.get(i).getClass().equals(ClassB)) {
          // perform ClassB specific processing:
      }
  }
  </code></pre>
  
  <p>Is this correct approach? Is there a better way to perform each class specific processing? I mean is there a way to avoid those <code>if else</code> constructs?</p>