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
- Object Equality in Scala
- Scala | Stateful Object
- Scala Tutorial – Learn Scala with Step By Step Guide
- Inner class in Scala
- Extending a Class in Scala
- Calling A Super Class Constructor in Scala
- Call a method on a Super Class in Scala
- Scala short <(x: Short): Boolean
- Scala short <(x: Char): Boolean
- Scala Extractors
- Scala | Partially Applied functions
- Scala String indexOf(String str) method with example
- Scala String contentEquals() method with example
- Scala Keywords
- Scala Int /(x: Int) method with example
- Scala Int /(x: Short) method with example
- Program to print Java Set of characters in Scala
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.