> Other than in unit tests, I'm hard-pressed to remember > ever wanting to write such code. An object will have a > list, and it will be read from a configuration file or > have a setter or something, but the times I'm wanted to > initialize it with two hard coded strings is, well, > never. > > In that case, I'm gonna have to write List<String> > explicitly, and Java seems much more reasonable typing > wise, and the benefits of more explicit type checking are > less of a burden to implement.
Good type inferencers can infer the type even if the string isn't hard-coded. The method that reads the data from the configuration file returns a List<String>, and the compiler knows this, so it can infer the type. The compiler knows that this method returns a list of strings because this method reads data directly from the file (the compiler knows that this data is of type string), and puts this data in a list (so the compiler knows that this is a list of strings).
Flat View: This topic has 370 replies
on 371 pages
[
«
|
151617181920212223
|
»
]