Hey! I just started learning java, and I am using this book called DATA Structures using JAVA. i am wondring if anyone has the sample of the code? if you do please post here.
: Hey! I just started learning java, and I am using this book called DATA Structures using JAVA. i am wondring if anyone has the sample of the code? if you do please post here. : : thanks : harry :
If you just started learning java, and have no previous programming experience, linked lists will prove to be extremely difficult to learn.
Doesn't your book have code for a linked list? [italic][blue]Just my 2 bits[/blue][italic]
public class LinkedListTest { public static void main(String a[]) { LinkedList LL = new LinkedList(); LL.add("hello"); // add a new element LL.add("This is another element"); // add another element to end of list LL.remove(0); // remove first element in list. LL.add("Last element in the list"); System.out.println(LL.toString()); // print out list } }
: my book has outline of code. not real programs that would run and give me the output. : Are you looking to create your own Linked List class or just use one from the API? [italic][blue]Just my 2 bits[/blue][italic]
public class LinkedListTest { public static void main(String a[]) { LinkedList LL = new LinkedList(); LL.add("hello"); // add a new element LL.add("This is another element"); // add another element to end of list LL.remove(0); // remove first element in list. LL.add("Last element in the list"); System.out.println(LL.toString()); // print out list } } [/code]
Comments
:
: thanks
: harry
:
If you just started learning java, and have no previous programming experience, linked lists will prove to be extremely difficult to learn.
Doesn't your book have code for a linked list?
[italic][blue]Just my 2 bits[/blue][italic]
:
[code]
import java.util.LinkedList;
// http://java.sun.com/j2se/1.3/docs/api/java/util/LinkedList.html
// also try Iterator class
public class LinkedListTest
{
public static void main(String a[])
{
LinkedList LL = new LinkedList();
LL.add("hello"); // add a new element
LL.add("This is another element");
// add another element to end of list
LL.remove(0); // remove first element in list.
LL.add("Last element in the list");
System.out.println(LL.toString());
// print out list
}
}
[/code]
:
Are you looking to create your own Linked List class or just use one from the API?
[italic][blue]Just my 2 bits[/blue][italic]
thanks everyone for helping me.
:
: thanks everyone for helping me.
:
If you've just started to learn Java, why don't you start from the beginning and actually learn to write a program that will run and produce output?
:
: thanks everyone for helping me.
:
Hey, copy and paste the code I've given earlier. It should print the list. It should give you the output you want.
Did everyone skip my message?
[code]
import java.util.LinkedList;
// http://java.sun.com/j2se/1.3/docs/api/java/util/LinkedList.html
// also try Iterator class
public class LinkedListTest
{
public static void main(String a[])
{
LinkedList LL = new LinkedList();
LL.add("hello"); // add a new element
LL.add("This is another element");
// add another element to end of list
LL.remove(0); // remove first element in list.
LL.add("Last element in the list");
System.out.println(LL.toString());
// print out list
}
}
[/code]