![]() |
VOOZH | about |
Object[] arr = Priority_Queue.toArray()Parameters: The method does not take any parameters. Return Value: The method returns an array containing the elements similar to the priority queue. Below programs illustrate the java.util.PriorityQueue.toArray() method. Program 1:
The PriorityQueue: [For, Geeks, To, Welcome, Geeks] The array is: For Geeks To Welcome Geeks
The PriorityQueue: [5, 10, 25, 20, 15, 30] The array is: 5 10 25 20 15 30
Object[] arr1 = Priority_Queue.toArray(arr[])Parameters: The method accepts one parameter arr[] into which all of the elements of the queue are to be copied. Return Value: The method returns an array containing the elements similar to the priority queue.
The PriorityQueue: [For, Geeks, To, Welcome, Geeks] The arr[] is: For Geeks To Welcome Geeks The arr1[] is: For Geeks To Welcome Geeks