3:11 pm - Sunday November 23, 6464

Remove object at the top of stack using E pop()

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

BACK

                  The pop() method is used to remove the object at the top of this stack and returns that object as the value of this function.

Example Program


import java.util.Stack;

public class Stackpop

{

	public static void main(String args[])

	{

		Stack n = new Stack();

		n.push("A");

		n.push("B");

		n.push("C");

		System.out.println("Object is removed : " + n.pop());

		System.out.println(" After the remove elements: " + n);

	}

}

Output

   Object is removed :C

   After the remove elements: [A, B]

BACK

Filed in: Java Examples

Comments are closed.