Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

COLLECTION PROBLEM PLEASE EXPLAIN!!

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys, finally i completed my collections and generics from k&b i was quite sure that i no everything about this chapter and can solve all its problems.......
but there are lots of things that k&b hadnt mentioned even......things are directly coming out in questions.
for example, in this question:


public static void main(string arg[])
{
Queue<String> q=new LinkedList<String>(); //how queue<string> is refering linked list,it should give error here.SO KINDLY EXPLAIN ABOUT THIS!!
q.add("ver");
q.add("wall");
q.add("dun");
showAll(q);
}
public static void ShowAll(Queue q)
{
q.add(new Integer(42));
while(!q.isEmpty())
System.out.println(q.remove()+" ");
}
what is the result?

I AM GETTING EVERYTHING in this program but only the commented line i am not getting at al l!!
ANS: ver wall dun 42

 
Greenhorn
Posts: 28
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its because LinkedList implements Queue interface also
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LinkedList implements List and Queue interface both..hence this statement is valid.
 
himanshu kesarwani
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohhhhh shit.......i just forgot it it just sliped from my mind.......
thank you guys 4 answering me patiently!!
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic