java判断某个数据的类型

                                   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

https://zhidao.baidu.com/question/523257311275383485.html

发布了81 篇原创文章 · 获赞 129 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/u013185349/article/details/105202467