InterviewSolution
| 1. |
Was Jdom Designed For Generics? |
|
Answer» JDOM was designed before Generics, but JDOM 2.x has taken the proven design of JDOM 1.x and extended it to use Generics where possible. Specifically, all Collections-based operations require appropriately TYPED inputs, and return appropriately typed results. Further, JDOM 2.x TAKES advantage of other Java 5 features like varargs, and co-variant return TYPES. Generics: Element.getAttributes () returns List<Attribute>, Element.getChildren () returns List<Element>, etc. Co-variant Return Types: Element. CLONE () returns Element, Text. Detach () returns Text, etc. I tried to use JDOM and get an error like this: java.lang.NoSuchMethodError (Or) java.lang.NoClassDefFoundError: org/xml/sax/SAXNotRecognizedException JDOM was designed before Generics, but JDOM 2.x has taken the proven design of JDOM 1.x and extended it to use Generics where possible. Specifically, all Collections-based operations require appropriately typed inputs, and return appropriately typed results. Further, JDOM 2.x takes advantage of other Java 5 features like varargs, and co-variant return types. Generics: Element.getAttributes () returns List<Attribute>, Element.getChildren () returns List<Element>, etc. Co-variant Return Types: Element. Clone () returns Element, Text. Detach () returns Text, etc. I tried to use JDOM and get an error like this: java.lang.NoSuchMethodError (Or) java.lang.NoClassDefFoundError: org/xml/sax/SAXNotRecognizedException |
|