Results 1 to 2 of 2

Thread: My CS project

  1. #1
    seanfmglobal is offline Member
    Join Date
    Nov 2010
    Posts
    40
    Rep Power
    0

    Default My CS project

    Hey guys I'll be up all night trying to figure this one out but I have plenty of questions that hopefully someone can assist me in.

    I'm currently working with Linked Lists and stuff of that sort but some things are still very confusing to me for example

    Java Code:
    public class ListNode<T> {
    	public T element;
    	public ListNode<T> next;
    	public ListNode<T> prev;
    	
    	public ListNode(T ele) {
    		element = ele;						
    		prev = next = null;					// doesn't make since previous equals next which equals null
    	}										
    	
    	
    	
    	
    }
    This is my node class. the prev = next = null; doesn't make since. How can I have more than two nodes in my list if this is true?


    Well I went ahead and added constructors so it now looks like this (I believe this is right)

    Java Code:
    public class ListNode<T> {
    	public T element;
    	public ListNode<T> next;
    	public ListNode<T> prev;
    	
    	public ListNode(T ele) {
    		element = ele;						
    		prev = next = null;					
    	}										
    	
            public ListNode(T ele, ListNode<T> n){
                     element = ele;
                     next = n;
            }
    
            public ListNode(T ele, ListNode<T> p, ListNode<T> n){
                     element = ele;
                     next = n;
                     prev = p;
            }
    	
    	
    	
    }

    I would think that is how a node should be set up but please let me know if I am wrong.
    Last edited by seanfmglobal; 09-26-2011 at 08:06 AM.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default Re: My CS project

    Hi. if I understand correctly you want to make linked list structure. So Can you explain what that is structure?
    Skype: petrarsentev
    http://TrackStudio.com

Similar Threads

  1. How to convert from Ant project to maven project?
    By jiapei100 in forum New To Java
    Replies: 0
    Last Post: 06-08-2011, 10:01 AM
  2. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 10:15 AM
  3. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 08:12 PM
  4. Could anyone help with project?
    By billdara in forum New To Java
    Replies: 1
    Last Post: 03-12-2008, 05:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •