How do I get rid of the uncheck conversion warning as a result of using PropertiesConfiguration from apache.commons
I prefer not to use SuppressWarnings. I prefer to write code that produces no complaints. I import the apache.commons class PropertiesConfiguration.
This file was created with a text editor:
numbers = 0.222,0.333
animals = dog,cat
I then read the file into an instance of Pro开发者_如何转开发pertiesConfiguration, say it is referenced by "pc".
List<String> myStringList = pc.getList("animals");
The call to getList() produces a compile-time warning about unchecked conversions. How do I improve this without SupressWarnings?
It looks like getList()
returns a generic List
object. How about using getStringArray()
instead which returns an array of String
s?
精彩评论