In implementing a binary tree in Java, should the node class be a separate class file independent of the BinaryTree
class, or should it be a default class in the same class file as the BinaryTree
class?
First Example: Node is in separate class file
BinaryTree.java
public class BinaryTree { ... }
BinaryTreeNode.java
public class BinaryTreeNode { ... }
Second Example: Node class is default class in same class file
BinaryTree.java
public class BinaryTree { .... } class BinaryTreeNode { ... }
I almost never see the use case for putting more than one class inside of the same class file, but this might be the first time I see it being useful. Does this make sense, or would this be considered sloppy code?