3:11 pm - Tuesday November 23, 6517

LinkedList Example Program for clone()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
*LinkedList Example Program for clone()
* @author   candidjava.com
* @description: Returns a shallow copy of this LinkedList.
*/
import java.util.*;

public class Clone {
public static void main(String args[]) {
LinkedList s = new LinkedList();// creats object for the LinkedList.
s.add(1);
s.add(3);
s.add(4);// add elements in LinkedList.
s.add(6);
LinkedList l = new LinkedList();// create second linkedlist.
l = (LinkedList) s.clone();// Creat clone of the LinkedList.
System.out.println("Cloned list l" + l);
}
}


Output:

Cloned list l [1, 3, 4, 6]

BACK

Filed in: Z-A All Java Codes

Comments are closed.