This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Surely there's an easier way to print a string and a number than using reflection. Let's give the original poster a chance to explain what they're asking and attempt some code first.
But I sure don't see anything requiring reflection yet.
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
I think he's asking whether if he passes a variable to a method, that method can print out the name of the variable and its value
i.e. printvar(i) will print out the name of the variable (i) and the value of the variable (10) as i = 10.
The answer is no, because Java is pass by value. What actually gets passed to the method is the value 10. The method knows nothing about the variable i.
Joanne Neal wrote:I think he's asking whether if he passes a variable to a method, that method can print out the name of the variable and its value
i.e. printvar(i) will print out the name of the variable (i) and the value of the variable (10) as i = 10.
The answer is no, because Java is pass by value. What actually gets passed to the method is the value 10. The method knows nothing about the variable i.
Thank you for your understanding of my question.
Your answer means that both the name of the variable and its value are needed for the function parameters: