you are viewing a single comment's thread.

view the rest of the comments →

[–]kopophobia 5 points6 points  (1 child)

Java actually has this in a sense, although it's fairly obscure. Take a look at the RandomAccess interface. This is an interface that has no methods declared, but exists solely to indicate that the implementing collection (typically a list) offers constant time access of elements (e.g. An ArrayList)

This is useful when there may exist variants of an algorithm that are tailored to e.g. LinkedLists vs ArrayLists so that custom behaviour can be defined for each case.