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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -