This is not after a function call, but after a constructor call. Line
Type type = new TypeToken<List<String>>(){}.getType();
creates an instance of the anonymous subclass of TypeToken , and then calls its getType() method. You can do the same in two lines:
TypeToken<List<String>> typeToken = new TypeToken<List<String>>(){}; Type type = typeToken.getType();
The Java Tutorial Anonymous Subclasses contains more examples. This is a somewhat peculiar use, since no methods are overridden, and the instance initialization block is not used. (For more information about blocking instance initialization, see Initializing Fields .)
source share