We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here's an example
class A
{
  A() {
  }
}
class B extends A
{
  B() {
  }
}
class C extends A
{
  C() {
  }
}
void draw()
{
  A obj;
  if (random(0, 1) > .5)
    obj = new B();
  else
    obj = new C();
   //what type is obj?
}
How can I tell what type object "obj" is?
Answers
println(obj.getClass().getSimpleName());
Here are 2 other ways to test the type of class.
Notice that the instanceof operator also recognises the object's parent class.
Thank you!