Java - Pass Class as Parameter for Comparison -
essentially want pass class parameter can preform instanceof comparison.
public class myclass { object o = something; public void mymethod(class c) { if(o instanceof c) { } } } where parameter class c class choose pass in else where. want able pass in class , make comparison.
any appreciated.
thanks
you can call class#isinstance(object obj):
if(c.isinstance(o)) { determines if specified
objectassignment-compatible object representedclass. this method dynamic equivalent of java languageinstanceofoperator.
Comments
Post a Comment