[Solved] Get the variable by its name [duplicate]


You can’t do that with local variables in Java. Local variables are variables you define inside a method. The names do not survive compilation step and are not available at runtime.

You can lookup fields via reflection via Foo.class.getField or obj.getClass().getField

1

solved Get the variable by its name [duplicate]