public static void main(String[] args) throws Exception {
int[] a = new int[] { 1, 2, 3 };
method(a);
}
public static void method(Object o) {
if (o != null && o.getClass().isArray()) {
Object[] a = (Object[]) o;
}
}
I should not know what type of parameter is oin method. How can I pass it to an array Object[]?
instanceof cannot be a solution, since a parameter can be an array of any type.
PS: I saw several questions about SO dedicated to casting an array, but no one (yet?) Where you don't know the type of array.
sp00m source
share