LinkedList Sort Reverse Shuffle Example

LinkedList Sort Reverse Shuffle Example

In this program, the operations like sorting, shuffling, reversing and printing the elements in the ascending order are done. These are very common operations used by every programmer now and then.

LinkedList Sort Reverse Shuffle Example

LinkedList Sort Reverse Shuffle
Output screen of LinkedList Sort Reverse Shuffle

A generics linked list object myList is created that stores strings only. With add() method, inherited from Collection interface, a few strings are added.

With static method sort() of Collections class, myList elements are sorted in ascending order automatically.

With static method reverse() of Collections class, myList elements (existing just before reverse() is called) are reversed.

The static method shuffle() of Collections class shuffles myList elements. Calling shuffle() method number of times prints different order of elements.

The contains() method, inherited from Collection interface, checks the element exists or not in the linked list. If the element passed as parameter exists, the method returns true else false. It can be used in the programming like this.

3 thoughts on “LinkedList Sort Reverse Shuffle Example

  1. mohan

    sir though you have not written as
    LinkedList myList = new LinkedList();
    A generics linked list object myList .how could it be done?plz clarify it?

  2. mohan

    sir though you have not written as
    LinkedList myList = new LinkedList();
    A generics linked list object myList .how could it be done?plz clarify it?

Leave a Reply

Your email address will not be published. Required fields are marked *