Below is a question that was raised by one of my friends during a discussion but both of us didn't know what the actual answer is.
public class Test {
static int i = 5;
static String str = "Welcome";
static Map<String, String> map = new HashMap<>();
}
In the object code, when JVM instance is created and it goes to create all three objects, where does it creates it
- Inside memory/metadata area
- Inside heap area
We know that memory area
holds all data related to class(including static references) and heap area
holds all instance variables of a class.
But for the class above
- int variable is created(We assume that it will be created in method area
- Not sure about the other two object(String and HashMap)
Correct us if we have misunderstood anything and help us in understanding how these variable will be store in java