• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding scjp 1.5

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Please don't cross-post the same question to multiple forums.
Your question has been answered in the SCJP forum.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic