System.out.println(someobj)
is always equivalent to:
System.out.println(String.valueOf(someobj));
And, for non-null values of someobj
, that prints someobj.toString();
In your case, you are doing println(obj.getClass())
so you are really doing:
System.out.println(String.valueOf(obj.getClass()));
which is calling the toString
method on the class.