Node – Single LinkedList Java Source Code

Node is an object which is built for storing information and it’s has a door the the other node, so it’s not storing other node but just the way to the other node. If it is singleNode, that is the node which just has only one way to the other node.

LinkedList? LinkedList is a nodes which is connected each other. If linkedlist cosist of singleNode, we can say that linked list is single-LinkedList. If still being confused by linkedlist try to understand with array : Node == integer data, LinkedList == array, so if linkedlist consist of many integer data which is continued on memory alloctaion, linkedlist consist of nodes which is connected by the pointer to the other node.

public class singleNode {

    private Object info;
    public singleNode next;

    public singleNode(Object info){
        this.info = info;
        next = null;
    }

    public void setInfo(Object info){
        this.info = info;
    }

    public Object getInfo(){
        return this.info;
    }

    public Object popInfo(){
        Object temp = this.info;
        this.info = null;
        return temp;
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation