Isn't?<String>
?unnecessary
No, it's necessary: without <String>
, the type of the variable would be Collection
, which is a raw type. Don't use raw types.
I suppose Java could have a notation for such contexts like Collection<>
, similar to the diamond notation, but it doesn't.
You either have to use Collection<String>
, or var
in language versions which support it (11 and higher).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…