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++: Boost interprocess memory mapped file error -

python - IO.UnsupportedOperation: Not Writable -

python - malformed header from script index.py Bad header -