how to print class name in java code example Example: Java print class type System.out.println(foo.getClass().getName());