11:17 pm - Sunday February 19, 2017

Stack Example Program for addAll(Collection c)

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

// Stack Example Program for addAll(Collection c)
/**
* @author   candidjava.com
* @description:Appends all of the elements in the specified collection to the end of this list,
in the order that they are returned by the specified collection's iterator (optional operation).

*/

import java.util.*;

public class Lines {
public static void main(String args[]) {
Stack s = new Stack();// creats objects for stack
s.push(1);
s.push(3);
s.push(4);
s.push(6);
Stack s1 = new Stack();// creats another stack
s1.push('g');
s1.push('d');
s.addAll(s1);// this method appends the elements from one stack to
// another stack.
System.out.println(s);
}
}

output:
[1, 3, 4, 6, g, d]

Filed in: Z-A All Java Codes

Comments are closed.