Quick actions

cmd+k|ctrl+k

Navigation

Languages

Linked List in Java

Snippet info

Language

Java

Visibility

public

Author

fakhryslacker

Created

2024-12-03T13:44:17.192435Z

Updated

2024-12-03T13:44:17.192435Z

class Node {
    String name;
    Node next;
}

public class Main {
    public static void main(String[] args) {
        Node current = null;
        Node first = new Node();
        Node second = new Node();
        Node third = new Node();

        first.name = "James Gosling";
        first.next = second;
        second.name = "2023";
        second.next = third;
        third.name = "Sun Microsystem";
        third.next = null;
        current = first;
        while (current != null) {
            System.out.println(current.name);
            current = current.next;
        }
    }
}
INFO