Skip to main content

need help with java-linked list

1 reply [Last post]
indianj
Offline
Joined: 2006-02-14

Hello everybody, I am studying linked list and i have question from the code below. what is "CircularLinkedList cll;" & "cll = new CircularLinkedList();" line do?

<br />
public static void main(String args[]) //a test<br />
	{<br />
		CircularLinkedList cll;<br />
		cll = new CircularLinkedList();<br />
		for (int n = 1; n <= 10; n++)<br />
		{</p>
<p>			Integer circle = new Integer(n);<br />
			cll.add(circle);<br />
			cll.push(circle);<br />
		}<br />
	//y<=21 prints upto 21 lines<br />
	for (int y = 1; y <= 21; y++)<br />
	{<br />
		Integer circle;<br />
		circle = (Integer)cll.pop();<br />
    System.out.println(circle);<br />
}<br />
}<br />
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
destin
Offline
Joined: 2006-05-05

It creates an instance of the CircularLinkedList class. Those lines can be
abbreviated into this:
[code]CircularLinkedList cll = new CircularLinkedList();[/code]
The same thing is happening in line 8:
[code]Integer circle = new Integer(n);[/code]
This creates an instance of the Integer class called circle.

Here are some useful links:
[url=http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html]The Java Tutorial: Instances and Class Members[/url]
[url=http://mindprod.com/jgloss/new.html]Java Glossary: new[/url]
[url=http://www.javaworld.com/javaworld/jw-04-2001/jw-0406-java101.html]Java World OOP[/url]

Message was edited by: destin