检索数组类名称 [英] Retrieving array class name
本文介绍了检索数组类名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题。
在一个方法中,我收到一个通用的Object作为参数,我必须检索类的名称
In a method I receive a general Object as parameter and I have to retrieve the name of the class
public void myMethod(Object o)
String className = o.getClass().getName();
...
}
它有效,除非我付给方法数组。
例如,如果传递给方法的数组是double( double []
), getClass()。getName()
给我退货 [D
It works, except when i give to the methods arrays.
For example if a pass to the method an array of double (double[]
), getClass().getName()
returns me [D
如何检索 double之类的内容[]
?
推荐答案
[D
意味着一系列双打。查看此链接有关类名的解释。为什么你喜欢 double []
之类的东西?
[D
means an array of doubles. Check this link for an explanation on class names. Why would you like something like double[]
instead?
这篇关于检索数组类名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文