Interface and implementation

hi all

in this program

factory= DocumentBuilderFactory.newInstance();

factory.setValidating(false);

doc=factory.newDocumentBuilder().parse(new File(filename)); Element root=doc.getDocumentElement();

System.out.println(root.getNodeName());

getRootChild(root);

NodeList nlist1=root.getChildNodes();

in this programelement is an "interface " it has method getChildNodes().

i just want to know where this method getChildNodes() would have been implemented.because here i'm just using the method of

interface without implementing it.

thanks in advance.

[626 byte] By [meena.chandrua] at [2007-10-3 3:25:35]
# 1

you are not implementing the interface but your are using jar file that provides you an implementation of those classes (xalan or xerces or ...).

So when you declare

Element root=doc.getDocumentElement();

you are just saying the JVM that you intend to use the result of getDocumentElement() as an implementation of Element.

in your code you should try the following lines to clear this thing:

Element root=doc.getDocumentElement();

System.out.println("class name is: " + root.getClass().getName());

System.out.println("is root instance of Element: " + (root instanceof Element) );

Marc

guerrinma at 2007-7-14 21:18:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...