Why I am getting the compilation error at lines 10,11,12 but there is no compilation errors at line 17,18, 20 what is the reasion.
I think If there is any error at lines 10,11,12 that will be repeat at line 17,18,19 also but I am getting the errors at lines 10,11,12 only why..? please any one can help me.. Thanks in advance.. Shammem.
Hi shameem , Because your showAll(Queue q) method can take any type of Queue object. If you want to make it type safe , then use something like this showAll(Queue<yourType> q). I think you have got it now.
When you declare a Collection with type parameter, that means it can only hold objects of that type and its subtypes and nothing else, this check is done at compile time.
In the showAll(Queue q) you are declaring a Queue without type parameter i.e <type>, so you can add objects of various type. Note you will get warning here. [ October 04, 2007: Message edited by: Ahmed Yehia ]