Aşağıdaki kodu düşünün:
DummyBean dum = new DummyBean();
dum.setDummy("foo");
System.out.println(dum.getDummy()); // prints 'foo'
DummyBean dumtwo = dum;
System.out.println(dumtwo.getDummy()); // prints 'foo'
dum.setDummy("bar");
System.out.println(dumtwo.getDummy()); // prints 'bar' but it should print 'foo'
Yani, kopyalamak istediğiniz dumiçin dumtwove değişim dumetkilemeden dumtwo. Ancak yukarıdaki kod bunu yapmıyor. Bir şeyi değiştirdiğimde dum, aynı değişiklik de oluyor dumtwo.
Sanırım, dediğimde dumtwo = dumJava sadece referansı kopyalar . Peki, yeni bir kopyasını oluşturmanın dumve bu dosyaya atamanın herhangi bir yolu var dumtwomı?


