如何在沒有包的情況下獲取類的名稱? - How to get the name of a class without the package?

問題:

In C# we have Type.FullName and Type.Name for getting the name of a type (class in this case) with or without the namespace (package in java-world). 在C#中,我們有Type.FullNameType.Name來獲取一個類型的名稱(在本例中是類),有或沒有命名空間(java-world中的包)。

What is the java equivalent to Type.Name ? 什麼是Java等同於Type.Name

Clearly there must be a better way than using Class.getName() and strip it of the package name manually. 顯然,必須有一種比使用Class.getName()更好的方法,並手動剝離包名稱。


解決方案:

參考一: https://en.stackoom.com/question/BHsT
參考二: https://stackoom.com/question/BHsT
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章