I’m writing a block of code that needs to generically output an Object. The Object can be anything, including an array of array of arrays. If it’s an array, it can be an array of primitives, or of class objects. How can I do this?
Basically:
Object x = new int[]{1, 2, 3, 4};
Object y = new int[][]{{},{1,2}};
Object z = "hello";
//etc...
Now I want a generic way to print x, y, or z.
For example, for y I would like “{{},{1,2}}”
edit: I see some answers that work if the right hand side is an Object[], but they don’t seem to work with primitive arrays
Example using GSON: