java 判断类型instanceof,不要再用try catch了

1.以前老是用try catch来判断对象类型,现在要用instanceof了,特别是spring integration有比较多会传递不同的payload type

 

if( sth instanceof String){

//string type

}else if(sth instanceof Integer){

//Integer type

}

你可能感兴趣的:(java)