Explanation: In this program, a LinkedList instance LL1 is created and fi ve integer objects added at the
beginning of the LL1. A new LinkedList instance LL2 is then created from LL1. LL1 list is cleared using
clear method. The contains method is then made use of to check whether list LL2 contains 2 as object;
the method returns true. Next, the index of the object 2 is displayed. The program also demonstrates the
usage of set method for setting the value at specifi ed index. Note the addLast method is equivalent to
add method seen earlier. For adding element anywhere in the list, the methods add(index, object) form ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.