<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.paulbui.net/wiki/index.php?action=history&amp;feed=atom&amp;title=NodeDemo.java</id>
	<title>NodeDemo.java - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.paulbui.net/wiki/index.php?action=history&amp;feed=atom&amp;title=NodeDemo.java"/>
	<link rel="alternate" type="text/html" href="https://www.paulbui.net/wiki/index.php?title=NodeDemo.java&amp;action=history"/>
	<updated>2026-10-24T12:29:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.8</generator>
	<entry>
		<id>https://www.paulbui.net/wiki/index.php?title=NodeDemo.java&amp;diff=14051&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;&lt;syntaxhighlight lang=&quot;Java&quot;&gt; public class NodeDemo { 	public static void main(String [] args) 	{ 		Node head = null; 		Node tail = null; 		 		Node n1 = new Node();	//create a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.paulbui.net/wiki/index.php?title=NodeDemo.java&amp;diff=14051&amp;oldid=prev"/>
		<updated>2017-11-14T15:08:48Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;Java&amp;quot;&amp;gt; public class NodeDemo { 	public static void main(String [] args) 	{ 		Node head = null; 		Node tail = null; 		 		Node n1 = new Node();	//create a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;Java&amp;quot;&amp;gt;&lt;br /&gt;
public class NodeDemo&lt;br /&gt;
{&lt;br /&gt;
	public static void main(String [] args)&lt;br /&gt;
	{&lt;br /&gt;
		Node head = null;&lt;br /&gt;
		Node tail = null;&lt;br /&gt;
		&lt;br /&gt;
		Node n1 = new Node();	//create an instance of the Node object&lt;br /&gt;
		n1.data = 2017;&lt;br /&gt;
		n1.next = null;&lt;br /&gt;
		&lt;br /&gt;
		Node n2 = new Node(2018);	//create an instance of the Node object&lt;br /&gt;
		n2.next = null;&lt;br /&gt;
		&lt;br /&gt;
		head = n1;&lt;br /&gt;
		tail = n1;&lt;br /&gt;
		&lt;br /&gt;
		//What does the memory diagram for this program look like?&lt;br /&gt;
&lt;br /&gt;
		System.out.println(&amp;quot;head.data =&amp;gt; &amp;quot; + head.data);&lt;br /&gt;
		System.out.println(&amp;quot;tail.data =&amp;gt; &amp;quot; + tail.data);&lt;br /&gt;
		&lt;br /&gt;
		n1.next = n2;&lt;br /&gt;
		tail = n2;&lt;br /&gt;
&lt;br /&gt;
		//What does the memory diagram for this program look like now?&lt;br /&gt;
&lt;br /&gt;
		System.out.println(&amp;quot;head.data =&amp;gt; &amp;quot; + head.data);&lt;br /&gt;
		System.out.println(&amp;quot;tail.data =&amp;gt; &amp;quot; + tail.data);&lt;br /&gt;
		&lt;br /&gt;
		System.out.println();&lt;br /&gt;
		&lt;br /&gt;
		print(head);&lt;br /&gt;
		&lt;br /&gt;
		System.out.println();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//This print method prints out all the nodes connected to each other&lt;br /&gt;
	public static void print(Node head)&lt;br /&gt;
	{&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		//currentNode is a reference that is used to iterate through the nodes&lt;br /&gt;
		for(Node currentNode = head; currentNode != null; currentNode = currentNode.next)&lt;br /&gt;
		{&lt;br /&gt;
			System.out.print(currentNode.data + &amp;quot; &amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
</feed>