0

I wish to construct the empty list of type List<String>. The best I can come up with that satisfies the type-checker is:

(List<String>) (Object) List.nil()

which is terribly ugly. Is there something better?

jameshfisher
  • 34,029
  • 31
  • 121
  • 167

2 Answers2

3

Here is another option:

List<String> l = List.<String>nil();
Shlomi
  • 4,708
  • 1
  • 23
  • 32
2

This should do it:

List<String> myList = list();
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95