Hi, after going through various code and APIs, one problem lead to another and right now I'm so confused that I'm not even sure if this is the right question!
I was given some sample code based on JDOM to work on XML files. It uses the collection framework which I am not familiar with (I was taught with JDK 1.4). In these sample codes (and many tutorials), I noticed many instances where an interface reference type invoked an interface method, yet I was unable to track down exactly which class implemented that interface.
In my n00b understanding, an interface method must be overridden somewhere! It does not make sense to use an abstract method. It is very frustrating and confusing to not be able to find that hidden class. Here is the code snippet in question:
String filename = xmlfile;
SAXBuilder builder = new SAXBuilder();
Document
doc = builder.build(new File(filename));
XPath oPath = XPath.newInstance("//Location");
List lPath = oPath.selectNodes(doc);
System.out.println("XML has "+ lPath.size() + " locations");
// why can lPath call size()? Who's overridding it?
Iterator i = lPath.iterator();
while(i.hasNext()) {
Element eLocation = (Element) i.next();
....
}
// same question with hasNext() and next()!
Thanks in advance!
(years later I'll be laughing at this, I know!)