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
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › javax › xml › soap › Node.html
Node (Java Platform SE 8 )
July 21, 2026 - 8 ... Detail, DetailEntry, SOAPBody, ... extnends the standard DOM Node interface with methods for getting and setting the value of a node, for getting and setting the parent of a node, and for removing a node....
🌐
University of Colorado Boulder
home.cs.colorado.edu › ~main › docs › edu › colorado › nodes › Node.html
Node
The method has made a copy of the linked list starting at source. The return value is an array where the [0] element is a head reference for the copy and the [1] element is a tail reference for the copy. ... Compute the number of nodes in a linked list. ... A wrong answer occurs for lists longer than Int.MAX_VALUE. public static <E> java.lang.Object[] listPart(Node<E> start, Node<E> end)
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());
    }
}
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Java Node Example - Java Code Geeks
September 20, 2021 - During the course of this article, we have seen various use-case featuring the Node class. Java Node class is actually being used as a generic name for any object template which is used in a building block for any non-sequential Data structure.
🌐
Apache NetBeans
bits.netbeans.org › dev › javadoc › org-openide-nodes › org › openide › nodes › Node.html
Node (Nodes API)
For example, a node representing a Java package will permit classes to be added. ... Get the set of actions that are associated with this node. This set is used to construct the context menu for the node. By default this method delegates to the deprecated getActions or getContextActions method depending on the value of supplied argument.
🌐
GitHub
github.com › joeferner › node-java › blob › master › README.md
node-java/README.md at master · joeferner/node-java
When you call a Java method through node-java, any arguments (V8/JavaScript objects) will be converted to Java objects on the v8 main thread via a call to v8ToJava (found in utils.cpp). The JavaScript object is not held on to and can be garbage collected by v8.
Author: joeferner
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › org › w3c › dom › Node.html
Node (Java Platform SE 7 )
Returns the DOMUserData associated to the given key on this node, or null if there was none. Since: DOM Level 3 · Overview · Package · Class · Use · Tree · Deprecated · Index · Help · Java™ Platform Standard Ed. 7 · Prev Class · Next Class · Frames · No Frames · All Classes · Summary: Nested | Field | Constr | Method ·
🌐
Virginia Tech
courses.cs.vt.edu › ~cs2114 › Fall2015 › CarranoDataStructures › JavaDocs › bag › Node.html
Node
Method · bag · java.lang.Object · bag.Node<T> Type Parameters: T - Type of object held inside of the Node · public class Node<T> extends java.lang.Object · Node To be used when implementing Carrano Data structures with a singly linked list. Might be used for BagInterface, or SimpleBagInterface.
🌐
GeeksforGeeks
geeksforgeeks.org › java › implementing-a-linked-list-in-java-using-class
Implementing a Linked List in Java using Class - GeeksforGeeks
July 11, 2025 - import java.io.*; // Java program to implement // a Singly Linked List public class LinkedList { Node head; // head of list // Linked list Node. // Node is a static nested class // so main() can access it static class Node { int data; Node next; // Constructor Node(int d) { data = d; next = null; } } // Method to insert a new node public static LinkedList insert(LinkedList list, int data) { // Create a new node with given data Node new_node = new Node(data); new_node.next = null; // If the Linked List is empty, // then make the new node as head if (list.head == null) { list.head = new_node; } else { // Else traverse till the last node // and insert the new_node there Node last = list.head; while (last.next != null) { last = last.next; } // Insert the new_node at last node last.next = new_node; } // Return the list by head return list; } // Method to print the LinkedList.
🌐
GitHub
github.com › joeferner › node-java
GitHub - joeferner/node-java: Bridge API to connect with existing Java APIs. · GitHub
When you call a Java method through node-java, any arguments (V8/JavaScript objects) will be converted to Java objects on the v8 main thread via a call to v8ToJava (found in utils.cpp). The JavaScript object is not held on to and can be garbage collected by v8.
Author: joeferner
🌐
Duke
www2.cs.duke.edu › csed › ap › subset › doc › ap › ListNode.html
ListNode (Advanced Placement Computer Science Java Subset Specification)
public ListNode(java.lang.Object initValue, ListNode initNext) Construct a list node with specified value and next node.
🌐
javaspring
javaspring.net › blog › calling-a-java-method-in-node-js
How to Call a Java Method in Node.js: Step-by-Step Tutorial with Example Code — javaspring.net
This tutorial will guide you through **directly calling a Java method from Node.js** using the `node-java` library, a popular bridge that connects Node.js to Java via the Java Native Interface (JNI). We’ll cover setup, writing a sample Java class, compiling it, and invoking its methods from ...
Top answer
1 of 3
20

This is a great question. In general, there are several approaches to language inter-operation:

  1. Running code in completely separate, isolated programs / processes, and using interprocess communication (IPC) or other networking protocols (TCP or higher level protocols built on top of TCP like HTTP, often with a REST-ful API, or some form of RPC system) to send information between the two processes that have been written in different languages.

  2. "Transpiling" one language into the other (e.g. using the JSweet or TeaVM transpilers to convert Java code to JavaScript code), and then creating a single application / process out of the original code in one language together with the transpiled code from the other language (which is now in the same language as the other code being built into that final application).

  3. Using a common intermediate language and low-level "native" interfaces that allow the code to interoperate. Most languages have some form of interoperation with C (because C is a common denominator supported by most operating systems). While this would not work with client-side JavaScript (though some of the principles are still be relevant with Native Client (NaCL)), with NodeJs, you can call into C code using node-gyp and cwrap. Once you are in C land, you can call into Java using the Java Native Interface (JNI) (though making it possible to call your Java code from C using JNI is probably more easily accomplished by letting SWIG autogenerate much of the boilerplate for this for you, rather than directly writing to the JNI specification).

As with all things, there are tradeoffs to the various approaches:

  • Approach #1:
    • Pros:
      • relatively straight-forward
      • works with almost any programming language
      • each subsystem is fully isolated from the other
      • each system can be debugged in a language idiomatic manner
    • Cons:
      • must define shared protocol
        • can result in redundant, duplicated code
        • protocols must be kept in sync
        • changes must be backwards-compatible or it will break
        • NOTE: protocol buffers can help with this
      • serialization/deserialization overhead
      • channel can add other overhead (e.g. if communicating between processes over the Internet as opposed to on the same machine via a UNIX domain socket)
      • must consider security of communication mechanism
        • encryption of data between subsystems
        • access control of the endpoints
  • Approach #2:
    • Pros:
      • no serialization/deserialization overhead
      • can debug final system using idioms for target language
    • Cons:
      • not all languages can transpile from one to the other
      • even if a transpiler supports the two languages:
        • often supports only a subset of the language
        • may need to fix/modify code to allow it to transpile
        • may need to fix/modify the transpiler
        • slightly different semantics in transpilation can lead to subtle, surprising bugs
      • no isolation between the subsystems
  • Approach #3:
    • Pros:
      • no serialization/deserialization overhead
      • more support than approach #2
      • no need to rewrite original code in either language
    • Cons:
      • must become an expert in esoteric tools like SWIG
      • result is very difficult to debug
        • stacktraces for NodeJS code suddenly contain C, JVM, Java code
        • debugging tools don't easily span languages (e.g. may end up stepping through JVM code interpreting Java, rather than stepping through the actual Java code)
      • ownership of objects, garbage collection across languages can lead to surprising / difficult to handle bugs if ownership semantics not correctly encoded
      • different threading models between languages or other semantic mismatches between languages can make entire system buggy / difficult to debug

Having used systems with approach #1 and approach #3 (as well as hearing of systems using approach #2), I would strongly recommend using approach #1 wherever possible; only if you find the serialization overhead to be untenable (and you are not able to optimize the communication protocol / mechanism to handle that problem) would I venture into the other waters. That being said, approach #2 can be successful if the languages are very similar (like transpilation from TypeScript to JavaScript), and approach #3 can be successful if the use of this mechanism is very limited in scope (e.g. just need to expose one small but frequently called / performance-sensitive function this way).

2 of 3
1

I know very little about java but can't you use a node-java bridge?

https://github.com/joeferner/node-java

I think this is use node-gyp so likely works along the line of #3

🌐
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.
🌐
Medium
medium.com › @andrewsouthard1 › linked-list-in-java-2e405bfc332f
Linked List in Java. A linked list is a data structure that… | by Andrew Southard | Medium
June 12, 2017 - In order to add a node to the linked list, we have to iterate through the linked list until we reach a node that has a null next value. Our getters and setters we wrote earlier are extremely useful here.
🌐
Javatpoint
javatpoint.com › java-program-to-create-a-singly-linked-list-of-n-nodes-and-count-the-number-of-nodes
Java program to create a singly linked list of n nodes and count the number of nodes - javatpoint
Java program to create a singly linked list of n nodes and count the number of nodes on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, linkedlist, tree, graph, pattern, string etc.
🌐
W3C
w3.org › 2003 › 01 › dom2-javadoc › org › w3c › dom › Node.html
W3C DOM Level 2 version 1.0 - Java API: Interface Node
public java.lang.String getLocalName() Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
🌐
javaspring
javaspring.net › blog › nodes-in-java
Understanding Nodes in Java: A Comprehensive Guide — javaspring.net
Single Linked List Node: In a singly linked list, each node contains data and a reference to the next node in the list.