简体   繁体   English

如何获得与数组类型关联的类?

[英]How to get the class associated to an array type?

Does anyone know a better way to write the following statement: 有谁知道写以下语句的更好方法:

example.mySpecialMethod(new MySpecialClass[0].getClass())

I need the array type, but I dont know if there is a better solution. 我需要数组类型,但是我不知道是否有更好的解决方案。 At the moment this example works for me, but perhaps someone knows a better way to do the same without the new keyword. 目前,该示例对我有用,但也许有人知道一种无需new关键字的更好方法。

new MySpecialClass[0]MySpecialClass[].class因此您可以使用:

example.mySpecialMethod(MySpecialClass[].class)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM