I know that when we create string literal, it goes inside permgenspace. My question is will it lie there for the life time of jvm even if that string literal is local to method. For example i have below code snippet:-
private static void testString1(){
String str1="tetingLiteral";
}
private static void testString2(){
String str2="tetingLiteral";
}
now from main method i call
testString1();
testString12();
will str1 and str2 will refer to same memory location.
My understanding is They will refer to same memory location(even if string literal is created inside method, it will stay there for lifetime of jvm). But still wanted to confirm it as i could not check it programmatically becoz no way to print string memory location