I'm taking Algorithms I on coursera and came across the implementation of a Data Structure called Bag.
http://algs4.cs.princeton.edu/13stacks/Bag.java.html
However I don't undertand why the use a Node class like this:
private static class Node<Item> {
private Item item;
private Node<Item> next;
}
Why is the Item in there? Why can't I use:
private class Node {
private Item item;
private Node next;
}
Is there a difference? Thanks