Linked Lists - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Linked Lists

indianjindianj Posts: 20Member
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

Comments

  • VilanyeVilanye Posts: 684Member
    : 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]

  • indianjindianj Posts: 20Member
    my book has outline of code. not real programs that would run and give me the output.
  • Josh CodeJosh Code Posts: 675Member
    : my book has outline of code. not real programs that would run and give me the output.
    :

    [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]

  • VilanyeVilanye Posts: 684Member
    : 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]

  • indianjindianj Posts: 20Member
    yes it would be nice if program will run and give me some sort of output.

    thanks everyone for helping me.
  • PerforatedPerforated Posts: 19Member
    : yes it would be nice if program will run and give me some sort of output.
    :
    : 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?
  • Josh CodeJosh Code Posts: 675Member
    : yes it would be nice if program will run and give me some sort of 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]
Sign In or Register to comment.