I have some Class objects in a List that I would like to convert into an array. Below is my code:
private static Class<?>[] getClasses(final Object[] params) {
List<Class<?>> classList = new ArrayList<>();
for (final Object param : params) {
classList.add(param.getClass());
}
return (Class<?>[]) classList.toArray();
}
I understand toArray() returns an Object[]. Is there a way to avoid the cast?