java - Is there any way to know the type of an Object? -


the scenario passing object parameter in method , want perform operations based on type of object within method.

sample code is:

method(object object){  //if object== string type print string     } 

try

if (object.getclass().getname().equals("class1name"))     //do something. 

the advantage of getclass instead of instanceof not need know class type @ compile time.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -