11:03 am - Tuesday October 24, 2017

LinkedList Example Program for 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
/**
*@Author:candidJava.com
*@Description:Remove top object of stack and return the object using pop() and class Pop
*/
import java.util.*;

public class LinkedListPop {
public static void main(String args[]) {
LinkedList<String> ls = new LinkedList<String>();// create ls object for
// LinkedList
ls.add("welcome");// add content to the ls
ls.add("to");// add content to the ls
ls.add("chennai");// add content to the ls
System.out.println("linkedlist:" + ls);
System.out.println("remove top ele of the list:" + ls.pop());/*
* remove
* top obj
* of the
* stack&
* return
* the obj
*/
System.out.println("linkedlist:" + ls);
}
}

OUTPUT:
linkedlist:[welcome,to,chennai]
remove top ele of the list:welcome
linhedlist:[to,chennai]

BACK

Filed in: Z-A All Java Codes

Comments are closed.