首页 > 其他 > 详细

String 深浅拷贝的测试---有待继续测试

时间:2015-12-16 17:07:00      阅读:152      评论:0      收藏:0      [点我收藏+]
public class TestString {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String str = new String();
        str = "12345";
        
        String str_1 = str;
        
        String str_2 = null;
        str_2 = str;
        
        String str_3 = new String();
        str_3 = str;
        
        System.out.println("str:"+str);
        System.out.println("str_1:"+str_1);
        System.out.println("str_2:"+str_2);
        System.out.println("str_3:"+str_3);
        
        
        str = "2345678";
        
        System.out.println("str:"+str);
        System.out.println("str_1:"+str_1);
        System.out.println("str_2:"+str_2);
        System.out.println("str_3:"+str_3);
    }

}

技术分享

总结:上述几种方式 String 都是深拷贝 

String 深浅拷贝的测试---有待继续测试

原文:http://www.cnblogs.com/huhuuu/p/5051440.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!