Reputation: 11
I'm trying to get the Class Name of a abstract
Child class from a Parent class object.
public abstract class Employee
public abstract class Faculty extends Employee
public class Professor extends Faculty
Employee bob = new Professor();
How do I get Faculty
useing one of the .getName()
, .getSimpleName()
or similar method from the bob
object?
Upvotes: 0
Views: 6608
Reputation: 4826
You are probably looking for bob.getClass()
. You can also use if bob instanceof Faculty
.
Upvotes: 1