Reputation:
public class sample1
{
private static Map m = new HashMap();
//....
//.....
//
public void fun(String str1, String str2, sample2 s )
{
String str = str1 + str2 + s.getName();
String value = m.get(str);
}
}
public class sample2
{
private String name;
// ......
// ........
pubic String getName()
{
return name;
}
}
Here my question is where exactly the variables (arguments of function fun) like str1, str2 and s (sample2 object) are stored, in heap or stack?
Upvotes: 1
Views: 79
Reputation: 420
You will never have any synchronization failure with str1 and str2, because those variables are strings, and the string class is immutable in Java.
Upvotes: 3