Java: how to get arguments passed to method that called this method?

后端 未结 6 1557
慢半拍i
慢半拍i 2020-11-28 14:25

In java, it is possible to get the class and method that called the current method (the method in which you get the StackTrace).

My question is, can I get the argume

6条回答
  •  感动是毒
    2020-11-28 14:50

    I'm not sure why you'd ever want to do this in Java?

    The only way I can think of is to create a custom wrapper object for the passed string, thus sending the reference to the wrapper instead of a new string each time.
    I'd advice against it, though, since it clutters your original code, and makes it even more error prone.

    Might this problem not be solved using a debugger, like the one built into eclipse, to inspect your state?

提交回复
热议问题