6. Array to List
List to Array
LinkedList<String> links =
new LinkedList<String>
(Arrays.asList(arrayname));
Arrayname = links.toArray(new String[links.size]);
11. Collections Methods
Process Example
Sorting Elements Collections.sort(list)
Sorting Elements in Reverse
Order
Collections.sort(list,Collections.reverseOrder())
Sorting with Comparator Collections.sort(list, new Customcomparotor())
Randomly ordering List
Elements
Collections.shuffle(list)
Reversing the Collection Collections.reverse(list)
Copying a List Collection.copy(copylist, list)
Filling a List Collections.fill(list, „R‟)
12. Collections Methods contd..
Process Example
Binary Search
Collections.binarySearch(list, search element)
Binary Search can be done only on the sorted list.
Adding all elements in an
array to a list
Collections.addAll(list, arrayname)
Finding no. of occurance
(frequency) of an element
Collection.frequency(list , “search element”);
To check whether lists have
common elements
Collections.disjoint(list1, list2)
16. Interface Queue
Implements Queue interface
Orders ele. by natural ordering or by
specified Comparator
Insertion – in sorted order
Deletion - from the front of the Queue
Methods for
Inserting
Removing
Inspecting elements
PriorityQueue
17. PriorityQueue Operations
PriorityQueue <Double> Que = new PriorityQueue <Double> ()
Operations
Que.offer(5.5)
Que.offer(1.2) // inserts ele. In sorted order
Que.offer(7.6)
Que.poll() //Remove the First Element.
Que.peek() //View First Element
Que.size() // Queue Size