java判断某个数据的类型
date instanceof Object (date是要判断的数据,Object是类型,如String,返回值是true)
String test_string = "test_string";
if (test_string instanceof String) //判断test_a的类型是否为String,返回true
{
todo;
}
Map test_Map = new HashMap<>();
List test_List = new ArrayList<>();
if(test_Map instanceof Map){
System.out.println("yes");
}
if(test_List instanceof List){
System.out.println("yes");
}
参考:https://blog.csdn.net/weixin_42553433/article/details/88070083