このコードを作成しましたが、実行時に次のエラーが発生します。
[Ljava.lang.Object; cannot be cast to [[Ljava.lang.String;
私を助けてください、ありがとう!!!
public java.util.List<String> concatAll(java.util.List<java.util.List<String>> mergedList) {
java.lang.String [][] mergedArray = (String[][])mergedList.toArray();
Iterator<java.util.List<String>> itr = mergedList.iterator();
java.util.List<String> list1 = itr.next();
java.lang.String [] firstArray = (String[])list1.toArray();
int totalLength = firstArray.length;
for (String[] array : mergedArray) {
totalLength += array.length;
}
String[] result = Arrays.copyOf(firstArray, totalLength);
int offset = firstArray.length;
for (String[] array : mergedArray) {
System.arraycopy(array, 0, result, offset, array.length);
offset += array.length;
}
java.util.List<String> finalList = Arrays.asList(result);
for (String list : finalList)
System.out.println(list);
return finalList;
}