CrazyEngineers
  • ashie
    ashie

    MemberJun 15, 2012

    clone() object....

    why do we need to use clone() object...
    can anyone tell me sme scenario where we can use this.
    an eg. can also be appreciated...
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • ashie

    MemberJun 15, 2012

    why do we need to use clone() object...
    can anyone tell me sme scenario where we can use this.
    an eg. can also be appreciated...
    Are you sure? This action cannot be undone.
    Cancel
  • ankur8819

    MemberJun 15, 2012

    ashie
    why do we need to use clone() object...
    can anyone tell me sme scenario where we can use this.
    an eg. can also be appreciated...
    you do cloning if you need say a local copy of an Object.When you are going to modify the current object but you need to have previous state of your Object as well.
    Refer to
    <a href="https://javapapers.com/core-java/java-clone-shallow-copy-and-deep-copy/" target="_blank" rel="nofollow noopener noreferrer">Java Clone, Shallow Copy and Deep Copy - Javapapers</a>
    for more info
    Are you sure? This action cannot be undone.
    Cancel
  • Vikash Verma

    MemberJun 19, 2012

    You need to create clone of an object when you want to create a new object having same state as another existing object without calling the constructor,basically it prevents the calling of constructor for creation of new object...😎
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register