import java.util.*; public class Example1 { static class Node { int data; Node left, right, parent; Node(int d) { data = d; left = right = parent = null; } } public static void main(String[] args) { Node root = new Node(1); Node left = new Node(2); Node right = new Node(3); root.left = left; root.right = right; left.parent = root; right.parent = root; } }
import java.util.*; public class Example2 { static class Node { int data; Node next, parent; Node(int d) { data = d; next = parent = null; } } public static void main(String[] args) { Node head = new Node(1); Node second = new Node(2); Node third = new Node(3); head.next = second; second.next = third; second.parent = head; } }Package library: This method belongs to the Java standard library and is part of the java.lang.Object class.