For example, say I wanted to \"extract\" String[] fruits = {\"Pear\", \"Banana\", \"Apple\"};
into three separate variables, eg:
for (int i=0; i
The question is not why you want to do it but 'what are you going to do with it?'. So suppose at runtime variable with the name fruits2
magically appeared on the stack of your method. Now what? You had to know its name at compile time to take advantage of it. Reflection will not help you access local variables.
Anyway, I would be interested if you described more detailed use case.