The getClass() method is utilized to return the run-time class representation of the stated object.
Method Definition: def getClass(): Class[Char]
Return Type: It returns the class of the stated object.
Example: 1#
// Scala program of getClass() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying getClass() method
val result = 'a' .getClass
// Displays output
println(result)
}
} |
Output:
char
Example: 2#
// Scala program of getClass() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying getClass() method
val result = '5' .getClass
// Displays output
println(result)
}
} |
Output:
char