*
The moose likes Certification Results and the fly likes regarding scjp 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Certification Results
Bookmark "regarding scjp 1.5 " Watch "regarding scjp 1.5 " New topic
Author

regarding scjp 1.5

anveshana bandu
Ranch Hand

Joined: Oct 09, 2007
Posts: 42
PriorityQueue<String> que=new PriorityQueue<String>();

que.add("silpa");
que.add("swati");
que.add("roopa");
System.out.println(que);
System.out.println(que.poll());
System.out.println(que.peek());

output:::[roopa, swati, silpa]
roopa
silpa

mydoubt:::why did the elements in the list are not in sorted order??i feel silpa and swati should be interchanged.so that they will be in sorted order.
i understood the functionality of poll() and peek()..my doubt is in what order the elements are printed in case of strings if we print the whole collection that is queue.
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Hi there,
Please don't cross-post the same question to multiple forums.
Your question has been answered in the SCJP forum.


SCJP 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding scjp 1.5
 
Similar Threads
urgent please
doubt in scjp 1.5
How is priority determined?-Collection Doubt
Priority Queue problem
PriorityQueue()