class Animal {
public Animal(String aType) {
type = aType;
}
public String toString() {
return "This is a " + type;
}
private String type;
}
public class MainClass {
public static void main(String[] a) {
Animal pet = new Animal("a");
if (pet.getClass() == Animal.class) {
System.out.println("it is an animal!");
}
}
}
it is an animal!