The "E" is a placeholder for a type (String, Integer, etc). Something like E is used when you're defining a "template". Java has the ability to provide a "generic" template class, which can be used to create a class meant to handle a particular type. So if you had a template class Blah<E>
, you could instantiate a class of type Blah<String>
... and then, bam, you have an Blah that only handles String objects.
In this case, you have a generic interface. You're defining a generic class that uses the generic interface, which is handled the same way.
Now, an interface is basically just a "specification" that guarantees your class implements particular methods. So when you have a class Meatball that implements Woogie which specifies methods X, Y, and Z, that means the rest of the java world now knows Meatball is guaranteed to have the methods X, Y, and Z.
What you need to do, when implementing a generic interface such as ArrayQueue<E>
, is continue to define the class with E instead of the type you actually might use ArrayQueue to handle. When you actually instantiate the class, if you want your ArrayQueue to store strings, you'd say
ArrayQueue<String> myQueue = new ArrayQueue<String>
... But then later you can use it again, and replace String with Integer when creating "theirQueue". Java will enforce that each ArrayQueue only contains a particular type of object.
In summary, you need to implement all the methods that Queue guarantees (which you listed), keeping it generic in your ArrayQueue<E>
class, so Java won't whine about your usage of the Queue interface.