Related Examples
 

Java LinkedList clone Example

LinkedList class clone method example. This example shows you how to use clone method.


LinkedList class clone method example.public Object clone() Returns a shallow copy of this LinkedList.

Here is the code

/**
 * @ # Clone.java
 * A class repersenting use to Clone method of LinkedList class in java.util package
 * version 15 May 2008
 * author Rose India 
 */
import java.util.*;

public class Clone {

    public static void main(String args[]) {
        LinkedList list = new LinkedList();
        int i = 0;
        String str = "Rose India";

        //Add the specified element to the end of this list.
        list.add(i);
        list.add(str);
        System.out.println("list = " + list);
        
        //Creat clone of the LinkedList
        List list1 =(LinkedListlist.clone();
        System.out.println("list1 = " + list1);
        

    }
}

Output
list = [0, Rose India]
list1 = [0, Rose India

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US