How is the Comparable interface a marker interface, with its compareTo () method?


How is the Comparable interface is marker interface, even though it defines a compareTo() method? Please explain detail.

A marker interface is just a design pattern. So even if you read around "X is a marker interface" this doesn't really mean anything apart from "X is an interface with no methods declared".

Since Comparable<T> has one method then it is not used as a marker interface.

A marker interface is useful when you want to attach data to a type to be able to use this data in specific situations, this is not the case of Comparable, which is used to provide an effective interface.

I don't even think that the definition of marker interface is used in javadoc to describe empty intefaces such as Serializable (not sure about it though).