Given the data structure for which an iterator is defined. It contains elements that can be compared with each other by value. The type of such a structure can be defined as Iterable<T> , while T implements the interface Comparable<T> .

How to correctly declare a class for such a structure?

    1 answer 1

     class Smth <T extends Comparable<T>> implements Iterable<T> 

    It seems to compile: http://ideone.com/yKCpLI

    • Why implements Comparable<Smth<T>> ? In condition only T comparable - Sergey
    • @Sergey, oh. Instead of an iterator, I thought about the comparator in the first sentence. So, too much. - Qwertiy