/** *@author:candidjava.com *@description:Stack example program for clone() */ import java.util.Stack; public class StackClone { public static void main(String[] args) { Stack s1 = new Stack(); // creating first stack for (int i = 1; i <= 10; i++) { s1.push(i); } System.out.println("First Stack peek value : " + s1.peek()); Stack s2 = (Stack) s1.clone(); // creating the clone of first stack System.out.println("Second Stack peek value : " + s2.peek()); } }
Stack 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 |
OUTPUT:
Filed in: Z-A All Java Codes