is possible get variable name?
For example:
String nameOfCar = "audi";
Now print the result:
System.out.println(nameOfCar.getVname???or something similar);
Screen:
nameOfCar
You can get all field name by reflection
Class yourClass = YourClass.class
Field[] fields = yourClass.getFields();
for(Field f: fields){
f.getName();
}
or if you want mapping then go for Map
Map<String, String> propertyToValueMap
if you are trying to read method's local variable name, then it is not that simple to fetch also a signal that you are doing something wrong
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With