Reputation: 169
final SomeObjectType[] list = webserviceResponse.getArrayOfObjects();
if (list != null) {
final List<SomeObjectType> responseList = Arrays.asList(list);
for (final SomeObjectType prt : responseList) {
// doing some factory conversion.
}
}
IntelliJ IDEA is giving me the warning
Unnecessary 'Arrays.asList' call
while I'm converting my array to a List
. Why?
Can someone answer simply?
Upvotes: 2
Views: 1872
Reputation: 3099
IntelliJ warns you about that because you could simply do
if (list != null) {
for (final SomeObjectType prt : list) {
// do something
}
}
This works because arrays also have an iterator.
Upvotes: 2