Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Reply to Thread

Post a reply to the thread: Need help with java, a toString method in LinearNode class?

Your Message

Click here to log in

What comes after M0nday

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Rate Thread

You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.

Topic Review (Newest First)

  • 06-28-2012, 01:29 AM
    sohizzle

    Need help with java, a toString method in LinearNode class?

    I have written the linearNode class but need help with toString method which returns the string version of the element only. Next field is not returned


    public class LinearNode<T> {
    private LinearNode<T> next;
    private T element;

    public LinearNode(T elem) {
    this.next = null;
    this.element = elem;
    }

    public LinearNode(){
    this.element = null;
    this.next = null;
    }

    public T getElement(){
    return(this.element);
    }
    public void setElement(T elem){
    this.element = elem;
    }
    public LinearNode<T>getNext(){
    return(this.next);
    }
    public void setNext(LinearNode node){
    this.next = node;
    }

    public boolean equalElement(LinearNode<T> node) throws NullPointerException{
    if(this.element.equals(node.getElement())){
    return true;
    }
    else{
    return false;
    }
    }

    public String toString(){
    ???????????????

    }

Posting Permissions

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