I wanna a method that would loop any type array and print them, I have written the following:
public static <T> void printArray(T[] arr){
for(T t: arr){
System.out.print(t+" ");
}
System.out.println("");
}
but this one only works for class arrays, what if I have a char[]
instead of a Character[]
, or a int[]
instead of an Integer[]
, or is there a way to cast them before hand? Thanks