[英]The parameter is ArrayList<T> and how can I get the T's className
[英]How can I get the classname at runtime, but only the classname?
如何在運行時獲取類名,但只能獲取實際的類名,而不能獲取整個“ com.xyz.etc”。 ?
我的意思是只說最后一段之后的名字
您必須將以下代碼段用於對象:
yourObject.getClass().getSimpleName();
或用於課堂使用:
yourClass.class.getSimpleName();
此代碼僅返回類的名稱,不包含程序包名稱。
String className = object.getClass().getSimpleName();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.