Question about the life and memory space of a variable inside a function...

...inside a function, String cast is the same like define a String variable ?

I'm not exactly sure what you're leading up to, but forget about String objects altogether. They just aren't worth the memory costs.