Results 1 to 4 of 4
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Post To take a benefit by all, i have an important question

    For the benefit of all people here in the forum,
    i have a very important question,

    I dont understand the Clone(Clonable) interface at all,,,
    Can any1 wriite a short example so that we can understand this interface.

    I google it , it gives hard examples. !1:confused:

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,343
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by javanew View Post
    For the benefit of all people here in the forum,
    i have a very important question,

    I dont understand the Clone(Clonable) interface at all,,,
    Can any1 wriite a short example so that we can understand this interface.

    I google it , it gives hard examples. !1:confused:
    If you want an object of your class to be cloneable your class should implement the Cloneable interface and implement a clone() method. Also read the API documentation for the Object.clone() method.

    kind regards,

    Jos

  3. #3
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default

    Can u give a small example please ???

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,343
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by javanew View Post
    Can u give a small example please ???
    There you go:

    Java Code:
    public class MyClass implements Cloneable {
    	
    	private String member;
    	
    	public MyClass(String member) { this.member= member; }
    
    	public Object clone() {
    		MyClass copy= (MyClass)super.clone();
    		copy.member= this.member;
    		
    		return copy;
    	}
    	
    	public static void main(String args[]){
    
    		MyClass original= new MyClass("foo");
    		MyClass copy= (MyClass)original.clone();
    	}
    }
    kind regards,

    Jos
    Last edited by JosAH; 03-28-2010 at 01:31 PM.

Similar Threads

  1. pleaze an important requst
    By mash800 in forum NetBeans
    Replies: 1
    Last Post: 03-17-2010, 12:46 AM
  2. [SOLVED] something important i want to know
    By pheonix in forum New To Java
    Replies: 5
    Last Post: 04-11-2008, 06:44 PM
  3. IMPORTANT: Applet Problem Please Help!
    By nvidia in forum Java Applets
    Replies: 1
    Last Post: 01-22-2008, 02:25 AM
  4. Referer Problem : very Important
    By berkdulger in forum Java Servlet
    Replies: 1
    Last Post: 07-17-2007, 04:59 PM
  5. Important : Referer Problem
    By berkdulger in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-17-2007, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •