2016年11月20日

java 创建string对象机制 字符串缓冲池 字符串拼接机制

摘要: 1.String str = new String("hello"); 创建了2个对象,1.检查常量池中有没有hello,没有的话,创建对象放到常量池中,再创建对象放到堆中。如果常量池有hello对象,则只创建一个对象并放到堆中。 2.字符串常量池在方法区 3.String str = "hello 阅读全文

posted @ 2016-11-20 16:07 wantcrazy 阅读(832) 评论(0) 推荐(0) 编辑

导航