Java - inline initialized string array memory allocation on heap?
问题 String[] stringArray = new String[] { "abc", "xyz" }; Executing this line there are two String literals created "abc" and "xyz" in PERMGEN space. Since the initialization has a new operator I am not sure if there's any memory allocated on HEAP. Thanks guys. 回答1: All objects, except string literals, are created on the heap. From Java 7, string literals are created on the heap as well. In theory, escape analysis can prevent new object from being created on the heap and perhaps using the stack