Welcome to Java! This Nodes are like a blocks, they must be assembled to do amazing things! In this particular case, your nodes can represent a list, a linked list, You can see an example here:

public class ItemLinkedList {
    private ItemInfoNode head;
    private ItemInfoNode tail;
    private int size = 0;

    public int getSize() {
        return size;
    }

    public void addBack(ItemInfo info) {
        size++;
        if (head == null) {
            head = new ItemInfoNode(info, null, null);
            tail = head;
        } else {
            ItemInfoNode node = new ItemInfoNode(info, null, tail);
            this.tail.next =node;
            this.tail = node;
        }
    }

    public void addFront(ItemInfo info) {
        size++;
        if (head == null) {
            head = new ItemInfoNode(info, null, null);
            tail = head;
        } else {
            ItemInfoNode node = new ItemInfoNode(info, head, null);
            this.head.prev = node;
            this.head = node;
        }
    }

    public ItemInfo removeBack() {
        ItemInfo result = null;
        if (head != null) {
            size--;
            result = tail.info;
            if (tail.prev != null) {
                tail.prev.next = null;
                tail = tail.prev;
            } else {
                head = null;
                tail = null;
            }
        }
        return result;
    }

    public ItemInfo removeFront() {
        ItemInfo result = null;
        if (head != null) {
            size--;
            result = head.info;
            if (head.next != null) {
                head.next.prev = null;
                head = head.next;
            } else {
                head = null;
                tail = null;
            }
        }
        return result;
    }

    public class ItemInfoNode {

        private ItemInfoNode next;
        private ItemInfoNode prev;
        private ItemInfo info;

        public ItemInfoNode(ItemInfo info, ItemInfoNode next, ItemInfoNode prev) {
            this.info = info;
            this.next = next;
            this.prev = prev;
        }

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

        public void setNext(ItemInfoNode node) {
            next = node;
        }

        public void setPrev(ItemInfoNode node) {
            prev = node;
        }

        public ItemInfo getInfo() {
            return info;
        }

        public ItemInfoNode getNext() {
            return next;
        }

        public ItemInfoNode getPrev() {
            return prev;
        }
    }
}

EDIT:

Declare ItemInfo as this:

public class ItemInfo {
    private String name;
    private String rfdNumber;
    private double price;
    private String originalPosition;

    public ItemInfo(){
    }

    public ItemInfo(String name, String rfdNumber, double price, String originalPosition) {
        this.name = name;
        this.rfdNumber = rfdNumber;
        this.price = price;
        this.originalPosition = originalPosition;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRfdNumber() {
        return rfdNumber;
    }

    public void setRfdNumber(String rfdNumber) {
        this.rfdNumber = rfdNumber;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getOriginalPosition() {
        return originalPosition;
    }

    public void setOriginalPosition(String originalPosition) {
        this.originalPosition = originalPosition;
    }
}

Then, You can use your nodes inside the linked list like this:

public static void main(String[] args) {
    ItemLinkedList list = new ItemLinkedList();
    for (int i = 1; i <= 10; i++) {
        list.addBack(new ItemInfo("name-"+i, "rfd"+i, i, String.valueOf(i)));

    }
    while (list.size() > 0){
        System.out.println(list.removeFront().getName());
    }
}
Answer from David Pérez Cabrera on Stack Overflow
Top answer
1 of 1
11

Welcome to Java! This Nodes are like a blocks, they must be assembled to do amazing things! In this particular case, your nodes can represent a list, a linked list, You can see an example here:

public class ItemLinkedList {
    private ItemInfoNode head;
    private ItemInfoNode tail;
    private int size = 0;

    public int getSize() {
        return size;
    }

    public void addBack(ItemInfo info) {
        size++;
        if (head == null) {
            head = new ItemInfoNode(info, null, null);
            tail = head;
        } else {
            ItemInfoNode node = new ItemInfoNode(info, null, tail);
            this.tail.next =node;
            this.tail = node;
        }
    }

    public void addFront(ItemInfo info) {
        size++;
        if (head == null) {
            head = new ItemInfoNode(info, null, null);
            tail = head;
        } else {
            ItemInfoNode node = new ItemInfoNode(info, head, null);
            this.head.prev = node;
            this.head = node;
        }
    }

    public ItemInfo removeBack() {
        ItemInfo result = null;
        if (head != null) {
            size--;
            result = tail.info;
            if (tail.prev != null) {
                tail.prev.next = null;
                tail = tail.prev;
            } else {
                head = null;
                tail = null;
            }
        }
        return result;
    }

    public ItemInfo removeFront() {
        ItemInfo result = null;
        if (head != null) {
            size--;
            result = head.info;
            if (head.next != null) {
                head.next.prev = null;
                head = head.next;
            } else {
                head = null;
                tail = null;
            }
        }
        return result;
    }

    public class ItemInfoNode {

        private ItemInfoNode next;
        private ItemInfoNode prev;
        private ItemInfo info;

        public ItemInfoNode(ItemInfo info, ItemInfoNode next, ItemInfoNode prev) {
            this.info = info;
            this.next = next;
            this.prev = prev;
        }

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

        public void setNext(ItemInfoNode node) {
            next = node;
        }

        public void setPrev(ItemInfoNode node) {
            prev = node;
        }

        public ItemInfo getInfo() {
            return info;
        }

        public ItemInfoNode getNext() {
            return next;
        }

        public ItemInfoNode getPrev() {
            return prev;
        }
    }
}

EDIT:

Declare ItemInfo as this:

public class ItemInfo {
    private String name;
    private String rfdNumber;
    private double price;
    private String originalPosition;

    public ItemInfo(){
    }

    public ItemInfo(String name, String rfdNumber, double price, String originalPosition) {
        this.name = name;
        this.rfdNumber = rfdNumber;
        this.price = price;
        this.originalPosition = originalPosition;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRfdNumber() {
        return rfdNumber;
    }

    public void setRfdNumber(String rfdNumber) {
        this.rfdNumber = rfdNumber;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getOriginalPosition() {
        return originalPosition;
    }

    public void setOriginalPosition(String originalPosition) {
        this.originalPosition = originalPosition;
    }
}

Then, You can use your nodes inside the linked list like this:

public static void main(String[] args) {
    ItemLinkedList list = new ItemLinkedList();
    for (int i = 1; i <= 10; i++) {
        list.addBack(new ItemInfo("name-"+i, "rfd"+i, i, String.valueOf(i)));

    }
    while (list.size() > 0){
        System.out.println(list.removeFront().getName());
    }
}
🌐
Codecademy
codecademy.com › learn › getting-started-with-data-structures-java › modules › nodes-java › cheatsheet
Getting Started With Data Structures: Nodes Cheatsheet | Codecademy
A Java Node class has a .getNextNode() method with no parameters that returns the next class property. ... Learn about the computer science concepts of data structures and algorithms and build implementations of each from scratch in modern Java.
Discussions

Need guidance on creating Node class (java)? - Stack Overflow
Below is a simple example of the Node implementation, (i renamed Item to Value for readability purpose). It has to be implemented somehow like this, because methods signatures seems to be imposed to you. But keep in mind that this is definely not the best way to implement a LinkedList. public class ... More on stackoverflow.com
🌐 stackoverflow.com
Node in java?
A "node" is not really a specific thing, but a generalized concept; like you said, there are linked list nodes, tree nodes, graph nodes, etc. They follow a similar structure, but not exactly, so you aren't likely to find a one-size-fits-all class for them. If you want a linked list or a tree, use the container classes the stdlib provides. Don't try and roll your own but still pull in bits of the stdlib that weren't really designed with this in mind. If you want to build your own containers, then build them on your own. More on reddit.com
🌐 r/learnprogramming
3
2
November 17, 2021
Java Node class for a Graph - Code Review Stack Exchange
I'm using ArrayList to store adjacent nodes, and ArrayList to store the corresponding weights of the vertices. Is this efficient if I only use it for small inputs? Is it More on codereview.stackexchange.com
🌐 codereview.stackexchange.com
January 16, 2018
Java Nodes
Watched a video on youtube, looks like people who want to write their own LinekdList implementations also write their own Node class which makes a lot more sense to me. More on reddit.com
🌐 r/javahelp
15
2
July 21, 2017
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › org › w3c › dom › Node.html
Node (Java Platform SE 8 )
July 21, 2026 - 8 ... Attr, CDATASection, ... SOAPFaultElement, SOAPHeader, SOAPHeaderElement, Text, Text ... The Node interface is the primary datatype for the entire Document Object Model....
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Java Node Example - Java Code Geeks
September 20, 2021 - An Individual Node in java is a class that is used to create the individual data holding blocks for various data structures, which organize data in a nonsequential fashion.
🌐
University of Colorado Boulder
home.cs.colorado.edu › ~main › docs › edu › colorado › nodes › Node.html
Node
Each node contains a piece of data (which is a reference to an E object) and a link (which is a reference to the next node of the list). The reference stored in a node can be null. ... Java Source Code for this class (www.cs.colorado.edu/~main/edu/colorado/nodes/Node.java) , BooleanNode, ByteNode, CharNode, DoubleNode, FloatNode, IntNode, LongNode, ShortNode
🌐
Virginia Tech
courses.cs.vt.edu › ~cs2114 › Fall2015 › CarranoDataStructures › JavaDocs › bag › Node.html
Node
Node constructor which sets its data to be dataPortion and its following node to be nextNode.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-for-inserting-a-node-in-a-linked-list
Java Program For Inserting A Node In A Linked List - GeeksforGeeks
July 23, 2025 - Time complexity of append is O(n) where n is the number of nodes in the linked list. Since there is a loop from head to end, the function does O(n) work. This method can also be optimized to work in O(1) by keeping an extra pointer to the tail of the linked list/ Following is a complete program that uses all of the above methods to create a linked list. ... // A complete working Java program to // demonstrate all insertion methods // on linked list class LinkedList { // head of list Node head; // Linked list Node class Node { int data; Node next; Node(int d) { data = d; next = null; } } // Inserts a new Node at front // of the list.
Find elsewhere
🌐
DEV Community
dev.to › dhanush9952 › data-structures-creating-custom-node-classes-1e8
Data Structures: Creating Custom Node Classes - DEV Community
October 25, 2024 - Sure, let's continue the dev post on using custom node classes and data structures to solve problems: In addition to custom data structures, you can also use the built-in collection framework in Java, such as ArrayList, LinkedList, HashMap, TreeSet, etc.
🌐
University of Hawaii
www2.hawaii.edu › ~walbritt › ics211 › examples › Node.java
/ A generic Node class that Stores a reference to Data and the next Node
/** * A generic Node class that Stores a reference to Data and the next Node * * @author William McDaniel Albritton */ public class Node ... /** * Constructor - Used To Create EAch Object and Initialize DAta Fields. * * @param data2 initializes the data variable.
🌐
Williams College
cs.williams.edu › ~bailey › JavaStructures › doc › structure5 › structure5 › Node.html
structure5 Class Node<E>
A class supporting a singly linked list element. Each element contains a value and maintains a single reference to the next node in the list.
🌐
Medium
javafullstackdev.medium.com › java-nodes-explained-essential-building-blocks-for-linked-lists-trees-and-graphs-93b1163f922e
Java Nodes Explained: Essential Building Blocks for Linked Lists, Trees, and Graphs | by fullstackjavadev.in | Medium
June 2, 2024 - A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. Nodes in a binary tree are structured as follows: public class TreeNode { int data; TreeNode left; TreeNode right; // Constructor public TreeNode(int data) { this.data = data; this.left = null; this.right = null; } }
🌐
Williams College
cs.williams.edu › ~bailey › JavaStructures › doc › structure › structure › Node.html
Node
A class supporting a singly linked list element. Each element maintains a single reference to the next node in the list.
🌐
University of Colorado Boulder
home.cs.colorado.edu › ~main › edu › colorado › nodes › Node.java
// File: Node.java from the package edu.colorado.nodes
* * @note * Lists of nodes can be made of any length, limited only by the amount of * free memory in the heap. But beyond Integer.MAX_VALUE (2,147,483,647), * the answer from listLength is incorrect because of arithmetic * overflow. * @see * * Java Source Code for this class * (www.cs.colorado.edu/~main/edu/colorado/nodes/Node.java) * * @author Michael Main * (main@colorado.edu) * * @version Feb 10, 2016 * * @see BooleanNode * @see ByteNode * @see CharNode * @see DoubleNode * @see FloatNode * @see IntNode * @see LongNode * @see ShortNode */ public class Node ·
🌐
Apache
xml.apache.org › xalan-j › apidocs › org › apache › xalan › xsltc › runtime › Node.html
Xalan-Java 2.7.1: Class Node
java.lang.Object | +--org.apache.xalan.xsltc.runtime.Node ... This class is used as "wrapper" for dom nodes.
🌐
Learneroo
learneroo.com › modules › 99 › nodes › 497
Nodes - Learneroo
public class Main { public static void main(String[] args) { Node a = new Node(1); Node b = new Node(2); Node c = new Node(3); a.next = b; b.next = c; System.out.println(a.next.next.data); } } Please sign in or sign up to submit answers.
🌐
Reddit
reddit.com › r/javahelp › java nodes
r/javahelp on Reddit: Java Nodes
July 21, 2017 -

I'm trying to write my own implementation of a LinkedList and have come across Nodes (class LinkedList has Node head, Node tail). This is something I have never used before and I'm not sure what I'm doing. To use it, the IDE first prompted me to import org.w3c.dom.Node, why am I importing from what looks like a third party? (not import java.something.something). Also, what is a Node anyway? I read this here:

https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html

but did not understand the explanation. Thanks.

🌐
HCL Software
help.hcl-software.com › hcllink › 1.1.6 › flow_designer › concepts › c_fldes_nodes_java.html
Java Node - HCL Product Documentation
The Java Node invokes a Java class, thus performing user defined functionality based on the properties specified for the Java class to act on the input.