ujjawal, your method definition says that it can accept Number type or its super types only.
but the list you are passing to that method says that it can accept Number type or its any of its subtypes also. So as generic is compile time protection compiler cannot make sure that you will pass only Number type to that method, hence compiler error.
programming using OOP concepts makes life easier for software people. Its easy to debug, test, and most importantly it provides component reuse which is essential for faster development and to cope with changing requirements in software development.
thanks for reply.
so does it mean that elements in PriorityQueue are not stored in a sorted manner of any kind? and its just the order in which they get removed is determined by either the natural order or by a comparator.