import org.w3c.dom.*; import javax.xml.parsers.*; import java.io.*; public class NodeListExample { public static void main(String[] args) { try { // Create a new W3C Document object DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new File("example.xml")); // Get all the nodes in the document NodeList nodeList = document.getDocumentElement().getChildNodes(); // Print the node names for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); System.out.println(node.getNodeName()); } } catch (Exception e) { e.printStackTrace(); } } }In this example, the NodeList is used to get all the child nodes of the root element in an XML document. The for loop then prints out the name of each node in the list. The package library for this interface is the Java Standard Library.