You're missing a parenthesis on line 3.
I had to trace this through my
IDE to get your answer and it was a merry chase.
The "of" method of List doesn't actually return a List, since List is an interface, not a class. But it does return an ImmutableCollection, and ImmutableCollection
implements List, so get() is defined as a guaranteed member method for an ImmutableList. So digging around in ImmutableLiist I find — guess what? A get() concrete method implementation. So the abstract get() is realized by the concrete method of the object returned by the "of()" function.
And incidentally, the compiler whines. Because technically, it's not merely a List, it's a List<
String>, as determined by the argument types if the of() method.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.