How do I instantiate a JAXBElement<String> object?

Viewed 121875

I need to create one of these as the interface requires it. Can someone please let me know how to create one, as there doesn't seem to be a c'tor defined?

5 Answers

Other alternative:

JAXBElement<String> element = new JAXBElement<>(new QName("Your localPart"),
                                                String.class, "Your message");

Then:

System.out.println(element.getValue()); // Result: Your message

I don't know why you think there's no constructor. See the API.

Related