LinkedMaxHeap myHeap = new LinkedMaxHeap(); is giving those yellw underlined warnings why?
if this is Java, I got no clue :D But try to look it, not sure u must be doing something wrong so the IDE is telling ya :p
this is java my class is public class LinkedMaxHeap<T extends Comparable<T>> extends LinkedBinaryTree<T> implements MaxHeap<T> {.... }
ohh I figure it out it was Java...and yo are trying to make a new instance of your class, in this case is a new object of the type pf your class, right?
yes
umm, well does it compile, or it doesn't cuz sometime with warnigs, the program can still run... since is not an error...
it is runnig well and giving me desired output
but, i think i need to say something inthe <> next to LinkedMaxHeap
what does the warnings display?
References to generic type LinkedMaxHeap<T> should be parameterized
but the class says, LinkedMaxHeap<T extends Comparable<T>> extends LinkedBinaryTree<T> implements MaxHeap<T>
well my best guess is that the compaler is telling you, it expects you to specify the type of Class object being passed to the method. You could define it as the type as Object if you are not sure... The T there must be a type you choose, wheter is a user defined one (class, object, list , etc) or a primitive type (int, float, double, long double, etc).. That's what is my guess from I had seen...
by user defined, I meant the one of those type a programmer defines, like those in the ( ) I specify avobe...
Since you are trying to use Generic Types, you could look at this Tutorial I saw about it: Generic Types Tutorial: http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
thanks, i will.
No problem :)
You have 'extends' twice. You cannot extend multiple classes, you can only extend 1 but you can implement as many as you want.
Just saw this. You're getting the underlines because you are not specifying a type for your class, as fr33 noted. LinkedMaxHeap myHeap = new LinkedMaxHeap(); should be: LinkedMaxHeap<SomeType> myHeap = new LinkedMaxHeap<SomeType>(); SomeType is whatever type of objects you want to go into the heap. If you don't specify a type, you're basically losing any advantage the compiler can provide in terms of compile-time type checking. If you tell the heap what kind of objects are going into it, the compiler can verify that everything going into and out of the heap is of the appropriate type. If you do not, you put yourself at risk of run-time failure if you use the heap without caution. I think there are also some performance benefits to specifying the type, but I could be imagining that from somewhere.
Join our real-time social learning platform and learn together with your friends!