Q:

How do I print an array that has been converted to object? 

I've got a logger which accepts object as input, and it is rather convenient for me.  But now I've got to log an input which is of type int[].  I want to modify the method so it properly logs any array or Iterable. 
In c#, what I would do is this: 
int[]data=new int[10];
object tmp=data;

.....

if (tmp is IEnumerable)
{
     StringBuilder _tmp = new StringBuilder();
     foreach (var i in (IEnumerable)tmp)
     {
         if (_tmp. Length > 0)
         {
             _tmp. Append(",");
         }
         _tmp. Append(i);
     }
     var r = _tmp. ToString(); 
 }

I've tried checking int[] against Iterable (it's not), than I tried checking with tmp.getClass().isArray(), which works, but now I have trouble enumerating the members of that array.  I need a method that will work with any array or list of objects. 
How do I properly do this in Java? 

A:

You could use the methods in java.lang.reflect. Array like
Object obj = new int[] { 1, 2, 3, 4 };
try {
    int len = Array.getLength(obj);
    for (int i = 0; i < len; i++) {
        if (i ! = 0) {
            System.out.print(", ");
        }
        System.out.print(Array.get(obj, i));
    }
    System.out.println();
} catch (IllegalArgumentException iae) {
    iae.printStackTrace();
}

Output is

    1, 2, 3, 4

