To determine the class of a Scala object we use getClass method. This method returns the Class details which is the parent Class of the instance.
Below is the example to determine class of a Scala object.
Calling method with argument –
class: class scala.collection.mutable.WrappedArray$ofInt
In above example, Calling the printClass method with parameter demonstrates the class Scala.
Calling method without argument –
class: class scala.collection.immutable.Nil$
In above example, Calling the printClass method without parameter demonstrates the class Scala.
With additional get* methods –
person: class Boy person: Boy person: Boy person: Boy
Above code show how the additional get* methods
getName, getSimpleName, and
- Class and Object in Scala
- Scala | Case Class and Case Object
- Object Casting in Scala
- Scala | Stateful Object
- Object Equality in Scala
- Inner class in Scala
- Extending a Class in Scala
- Call a method on a Super Class in Scala
- Calling A Super Class Constructor in Scala
- Set in Scala | Set-2
- Set in Scala | Set-1
- Scala Map
- Scala | Either
- Scala Map take() method with example
- Scala | Value Classes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.