Declaring variables inside a function is not a problem in general, even a function you call 30 or 60 times a second, i.e. every frame. The alternatives such as using static variables is generally slower.
The only performance issue that would perhaps concern me is you have a String
variable. Strings variables can be expensive as each new String requires a memory allocation. Allocating them repeatedly will add to the memory burden and cause the garbage collector to run more perhaps often than you want.
I tend to avoid Strings for such performance reasons, except for text that is going to be read by someone where they are unavoidable. You can use them efficiently if you restrict how you use them, but I find it easier to not use them at all.