Get constructor name of object

Viewed 12644

How can I get name of object's class? I mean "Process" in this exampleenter image description here

I see two ways to get it. First one is to write a getter in this class like

 getClassName(){return "Process"}

But I suppose it will be an error if I try to call this method in object which doesn't belong to this class and hasn't got method like this.

And second one is using object instanceof Process. But maybe there is some way to make it better and more correctly?

4 Answers
Related