Java determine which class an object is

前端 未结 6 1801
悲&欢浪女
悲&欢浪女 2021-01-26 20:36

I have three classes (Carnivore, Herbivore, and Plant) that extend another class (Organism). How can I tell which subclass an

6条回答
  •  天命终不由人
    2021-01-26 20:52

    Java has an instanceof operator. However, that type of thing can be contrary to object-oriented design.

提交回复
热议问题