# Multiple classes in an (undefined) ArrayList?

**URL:** <https://discourse.processing.org/t/multiple-classes-in-an-undefined-arraylist/8291>\
**Category:** Beginners\
**Created:** [February 11, 2019, 7:14pm UTC](https://discourse.processing.org/t/multiple-classes-in-an-undefined-arraylist/8291 "2019-02-11T19:14:45Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [April 4, 2023, 10:58am UTC](https://discourse.processing.org/t/multiple-classes-in-an-undefined-arraylist/8291/14 "2023-04-04T10:58:17Z")

</div>

You can get any object to report the class it was instantiated from

```auto
// Object hierarchy
class A{ }
class B extends A { }
class C extends B { }

// Declare 3 variables of type A
A a,b,c;

// Now instantiate an object from each class
a = new A();
b = new B();
c = new C();

// Get each object to report its class name
println(a.getClass().getSimpleName());
println(b.getClass().getSimpleName());
println(c.getClass().getSimpleName());

```

---

_[View the full topic](https://discourse.processing.org/t/multiple-classes-in-an-undefined-arraylist/8291)._
