在java中的HashMap中获取变量类型 [英] Get variable type in a HashMap in java
本文介绍了在java中的HashMap中获取变量类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 HashMap< String,Object>
并存储了3种不同类型的数据(整数,字符串,长整数)。我发现具有特定键的值的类型是什么?
I have a HashMap<String,Object>
and stored some data from 3 different types (Integer,String,Long).
How Can I find out what is the type of a value with a specific key?
推荐答案
您可以调用 getClass
方法来查找对象的类型:
You can call the getClass
method to find the type of an object:
map.get(key).getClass()
这篇关于在java中的HashMap中获取变量类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文