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

[ad_1]

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

[ad_2]

solved Get the variable by its name [duplicate]