nameof equivalent in Java

前端 未结 4 525
生来不讨喜
生来不讨喜 2020-12-16 09:35

C# 6.0 introduced the nameof() operator, that returns a string representing the name of any class / function / method / local-variable / property identifier put

4条回答
  •  旧巷少年郎
    2020-12-16 10:37

    You can't.

    If you compile with debug symbols then the .class file will contain a table of variable names (which is how debuggers map variables back to your source code), but there's no guarantee this will be there and it's not exposed in the runtime.

提交回复
热议问题