开发者

How do I get rid of the uncheck conversion warning as a result of using PropertiesConfiguration from apache.commons

开发者 https://www.devze.com 2023-04-02 04:51 出处:网络
I prefer not to use SuppressWarnings.I prefer to write code that produces no complaints.I import the apache.commons class PropertiesConfiguration.

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 Strings?

0

精彩评论

暂无评论...
验证码 换一张
取 消