PDA

Click to See Complete Forum and Search --> : Java - LinkedList Tutorial Using JCC


GamerMax5
Jun 28th, 2007, 09:29 PM
I was peeking around on the internet for a while today and noticed that there are a lot of tutorials on the internet for Linked Lists in Java but they all re-invent the wheel. While this is great for people who don't have the first idea about LinkedLists, why re-type all that code when Java has done it for you? And there aren't many great tutorials out there for using the JCC and if they are, they tell you about the interfaces, not the actual classes.

So I decided to write two source files that demonstrate a very simplistic use of the LinkedList class. The actual main class file is well commented explaining everything that's going on with the code while the dummy demo class is pretty much self-explainitory.

I hope that anyone who uses it finds it useful and constructive criticism is welcome.

konbs
Dec 4th, 2007, 01:54 PM
A good one, but I would change this line:

LinkedList<Item> itemDatabase = new LinkedList<Item>();

to

List<Item> itemDatabase = new LinkedList<Item>();

The advantage would be if you decide one day to change the LinkedList to an ArrayList, there just one line, that has to be changed.

List<Item> itemDatabase = new ArrayList<Item>();

With the interface you wouldn't have to change other parts of you code.

GamerMax5
Jan 1st, 2008, 01:39 AM
Thanks for the heads-up. I wasn't really thinking "outside-the-box" when I wrote that. More or less I was flared up on how irritating it was for me to try and find something to help me with that topic.