[unchecked] unchecked generic array creation for varargs parameter of type List<String>[]
方法来源:
/**
* Returns a list of all possible combinations of the entered array of lists.
* Example: [["A", "B"], ["0", "1", "2"]]
* Returns: [["A", "0"], ["A", "1"], ["A", "2"], ["B", "0"], ["B", "1"], ["B", "2"]]
* @param <T> The type parameter
* @param elements An array of lists
* @return All possible combinations of the entered lists
public static <T> List<List<T>> createCombinations(List<T>... elements) {
List<List<T>> returnLists = new ArrayList<>();
int[] indices = new int[elements.length];
for (int i = 0; i < indices.length; i++) {
indices[i] = 0;
returnLists.add(generateCombination(indices, elements));
while (returnLists.size() < countCombinations(elements)) {
gotoNextIndex(indices, elements);
returnLists.add(generateCombination(indices, elements));
return returnLists;
}
到底哪里出了问题,我该如何修复它,因为我认为在代码中留下未经检查的警告不是一个好主意?
忘了提一下,我使用的是Java7。
编辑
:我现在还看到该方法有以下几点:
[unchecked] Possible heap pollution from parameterized vararg type List<T>
where T is a type-variable:
T extends Object declared in method <T>createCombinations(List<T>...)