public class MainClass {
public static void main(String[] argv) {
printArray(new int[]{1,2,3});
}
public static void printArray(Object x) {
if (x instanceof int[]) {
int[] n = (int[]) x;
for (int i = 0; i < n.length; i++) {
System.out.println("integers = " + n[i]);
}
}
if (x instanceof String[]) {
System.out.println("Array of Strings");
}
}
}
|