import java.util.*; class Node { int value; Node left; Node right; public Node(int val) { value = val; left = null; right = null; } } public class BinarySearchTree { Node root; //methods for inserting, deleting and searching in BST public Node getRightChild(Node current) { if (current != null) { return current.right; } return null; } }
import java.util.*; class Node { int value; Node next; public Node(int val) { value = val; next = null; } } public class LinkedList { Node head; //methods for inserting, deleting and searching in linked list public Node getRightNode(Node current) { if (current != null) { return current.next; } return null; } }This example shows a linked list implementation in Java where we can get the right node of any node using the getRight() method. Package/Library: This method is not associated with any specific package/library. It is a method that can be defined in any custom class that uses tree or linked list data structures.