I have looked all over for this answer and I'm leaning toward thinking that the answer is yes:
I am creating a mini app to help with static code analysis. In order to make it run as fast as possible I need to understand how the language Im using groovy/java will deal with these strings. The problem I am having is understanding weather the code:
space.matcher(line.get(index)).replaceAll("")
or
line.get(index)
when used in comparisons in if and while statements will save the string created by the Pattern.matcher().replaceAll() or retrieved by the retrieve from list to the stack as in other litteral creation such as:
String foo = "foofoo" //creates a string litteral, ref is saved to the stack
String fooTwo = "foofoo" //fooTwo==foo returns true since both have same ref to the litteral
I am Asking so that I may find out if when I make future refferences to the created or retrieved strings weather I am recreating the strings entirely or if I am just grabbing the refference to the litteral on the stack that I have already made so that future refferences to these same strings will be faster, or if I would be better off to save the strings locally as litterals at each step for faster access?