Is it possible to refer to a variable name in a Java method?
E.g. imagine a method stateTheObvious(String personOrThing) that returns the sentence:
"[personOrThing - the value of the variable] is the [name of the variable as it was the parameter calling the method]."
Examples:
String queen = "Elizabeth II";
stateTheObvious(queen);
-> "Elizabeth II is the queen."
String end = "This";
stateTheObvious(end);
-> "This is the end."
Possible? If yes, how?
EDIT: My main motivation is a generic method to create URL parameters:
String lastname = "Smith";
buildUrlParameter(lastname);