The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

public class Node
{
private Data data; //The Data Object to hold data part of the Node
private Node next; // The Node Object which holds reference to the next Node
//default constructor for Node
public Node(){
next=null;
}
//Method for setting the Node's Data
public void setData(Data data)
{
this.data=data;
}
//Method for setting the pointing part of the Node
public void setNext(Node next){
this.next=next;
}
//Method for getting the Node's Data
public Data getData(){
return (data);
}
//Method for getting the Nodes' pointing part
public Node getNext(){
return (next);
}
}

Data Class

/*This is Data Class Which Holds The Data Part of the Node*/
class Data
{
private String name; //String which is the Data Part of the Node
//Mutator method for setting the string
public void setData(String str){
this.name=str;
}
//Mutator method for getting the string
public String getData(){
return (this.name);
}
}

The output I was is to display the input but instead I am getting the sentinel value over and over.
Can any one help me fix this. I need it ASAP