I have this function;
static public void Print(Object[] arr) {
for(int i = 0; i < arr.length; i++)
System.out.println(i + " => " + arr[i]);
}
I want to use that for every primitive type array. Isn’t there any way to do that without overriding it for every primitive type?
Note: This is just an example function. I want to know the technique if there is one.
No, this is not possible. Array element types are not wrapped,
Object[]formal parameter is not applicable for e.g.int[]actual parameter. You have to write one method per primitive type, as injava.util.Arrays. Ugly, but the only way.