I want to create a new map every time the button is pressed. I want the names of the maps to be regular. I tried using ${} in the map name but it doesn't seem to work. is there any solution?
CodePudding user response:
There are a few ways to do this:
- Use the sprintf function:
String mapName = sprintf("map_%d", mapNumber);
- Use string interpolation:
String mapName = "map_${mapNumber}";
- Use a template string:
String mapName = map_${mapNumber}
;
CodePudding user response:
You may think you want this, but you don't. Information and meta-information should remain separate. Very likely, a Map of Maps will accomplish everything you want with dynamic names.