@XmlElements({
@XmlElement(name = "house", type = House.class),
@XmlElement(name = "error", type = Error.class),
@XmlElement(name = "message", type = Message.class),
@XmlElement(name = "animal", type = Animal.class)
})
protected List<RootObject> root;
where RootObject is super class of House,Error,Message,Animal
root.add(new Animal());
root.add(new Message());
root.add(new Animal());
root.add(new House());
//Prints to xml
<animal/>
<message/>
<animal/>
<house/>
but needs in order as declared inside @XmlElements({})
<house/>
<message/>
<animal/>
<animal/>
@XmlElements
is just acts as a container to have multiple@XmlElement
. Can you elaborately mention your actual need and with Code? – Matriculate