This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query with Cloning of an Object

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ShallowCloning : A new Object is created , but its variables refer to the same location and the default Object clone method only returns a shallow copy of an Object .



But this gives me (pav1.a) gives me only the value 10 (even though i chnaged to 20 with pav2.a=20)

why the value of a is not copied .


Any ideas ??
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


int are primitive types and are not obejcts so they dont live in heap. Clone will just copy the value of int and create a new int. Any changes to primitive types will not be reflected.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great Balu
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic