previous | start | next

## Double Dispatch Example

- `DirectoryNode node = new DirectoryNode(new File(".."));
  node.accept(new PrintVisitor());
  `
- `node` is a `DirectoryNode`
- Polymorphism: ``node.accept`` calls `DirectoryNode.accept`
- That method calls `v.visitDirectoryNode`
- `v` is a `PrintVisitor`
- Polymorphism: calls `PrintVisitor.visitDirectoryNode`
- Two polymorphic calls determine
- - node type
  - visitor type

previous | start | next