How to determine whether a class is equal to or extends another class (Java)

So I'm writing a minecraft mod, in which I successfully added a pistol, which can handle various support classes, ray tracing, sound, GUI overlay and so on When the pistol works perfectly, I want to add support for other mods and use my weapon class as the base class to add my own weapon My problem is how to let my support class know that an item class is actually a custom class that extends my weapon class Basically, what I need to know is whether I can use the basic data and functions of my weapon to cast the instance of the class into my weapon class for processing (please note that I have obtained the instance of the item class extended by the weponitem class) Who knows a good way to do this?

Solution

if(object instanceof SomeClass)
if(object instanceof SomeClass)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>