public class NodeFun
{
	public static void main(String [] args)
	{
		Node head = null;
		Node tail = null;
		
		Node n1 = new Node();	//create an instance of the Node object
		n1.num = 2007;
		n1.next = null;
		
		Node n2 = new Node();	//create an instance of the Node object
		n2.num = 2008;
		n2.next = null;
		
		//1) What does the memory diagram for this program look like at this point?
		
		head = n1;
		tail = n1;
		
		//2) What does the memory diagram for this program look like here?

		System.out.println("head.num => " + head.num);
		System.out.println("tail.num => " + tail.num);
		
		n1.next = n2;
		tail = n2;

		//3) What does the memory diagram for this program look like now?

		System.out.println("head.num => " + head.num);
		System.out.println("tail.num => " + tail.num);
		
		System.out.println();
		
		print(head);
		
		System.out.println();
	}
	
	//This print method prints out all the nodes connected to each other
	public static void print(Node head)
	{
		//currentNode is a reference that is used to iterate through the nodes
		for(Node currentNode = head; currentNode != null; currentNode = currentNode.next)
		{
			System.out.print(currentNode.num + " ");
		}
	}
}