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 Equality in Scala
- Scala | Stateful Object
- Object Casting 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
- Scala Tutorial – Learn Scala with Step By Step Guide
- Scala Map
- Set in Scala | Set-2
- Scala | Either
- Set in Scala | Set-1
- Scala ListBuffer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.