Here's how to print the datatype of an object or a primitive value to the console:

  1. Object:
    Object myobject = “new”;    // note: String is an object