public class SongIterator<T,L> implements Iterator<Song<T, L>> {}

Recommended Answers

All 4 Replies

Which part is the problem? Is there really nothing in the {}?
How is the class Song declared?

What that code does is throw a compiler error.

The statement, incomplete though it is declares a class SongIterator which expects two more classes, T and L. The class implements Iterator which is an Interface from the Collections API. java.util.Iterator operates on a collection of Songs(another class) which also expect classes T and L. The class definition is empty.

If you put this into your eclipse IDE and have the proper library jars available it will show you that there are unimplmented methods etc....

when I did this and createda dumy class of Song it requires methods hasNext() which returns a boolean, next() which returns a Song<T, L> and remove() which returns void.

commented: Most useful explanation. Thanks +2

The missing methods are because the class is declared to implement an Iterator, but has an empty body that (obviously) doesn't implement the methods declared in the Iterator interface ( http://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html ).

ps Speaking technically, T and L are type variables, not necessarily classes. A type variable can be any non-primitive type you specify: any class type, any interface type, any array type, or even another type variable ( http://docs.oracle.com/javase/tutorial/java/generics/types.html )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.