Viewing libraries through Guava I saw this strange signature in the readLines method from the Files class:
public static <T> T readLines(File file,
Charset charset,
LineProcessor<T> callback)
I know a little about generics in java, but it puzzled me.
What does double t mean here? And why the first in angle brackets?
UPDATE : Thanks for the answers. I still don't understand why I should use T inside brackets. Why, for example, it cannot be simple:
public static <> T readLines()
or
pulibc static <K> T readLines()
Or does the java syntax determine that ONLY the letter should be used?
Now this is even weirder:
static <T> void fromArrayToCollection(T[] a, Collection<T> c) {
how can a method have a return type and be invalid?
source
share