There are around 10 different types of 2D arrays of varied sizes. eg:
int arr1[][];
float arr2[][];
long arr3[][];
String arr4[][];
Each array needs to be printed at different intervals during the program execution. There is a method defined print2DArray() which takes the 2D array as parameter calculates the number of rows and columns and print the array. But since the arrays are of varied datatypes overriding methods need to be written for each data type.
Can we create a variable as: String arrName;
and pass it to the method print2DArray() and decode the String to obtain the array to be printed.
eg:
if method is called as: print2DArray(arr2);
and method is defined as:
void print2DArray(String arrName){
**Some code to identify which array is reffered by arrName to print**
}
Objectand recognize type byinstanceof?