简体   繁体   中英

When we instantiate in string in java using new operator where is 3rd object created

In Java String S=new String(" "); will create 3 different objects, 1 in string pool area and 1 more in non string pool area, can any 1 tell me how and where is the 3rd object created

In Java String S=new String(" "); will create 3 different objects

No it won't. It only creates the two you were talking about (and only one new one if the string " " is already in the intern pool).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM