Java Program to Pop Items From the Stack Represented by the LinkedList

Java Program to Pop Items From the Stack Represented by the LinkedList

Java Program to Pop Items From the Stack Represented by the LinkedList

// Java program to pop items from the stack 
// represented by the LinkedList

import java.util.LinkedList;

public class Main {
  public static void main(String[] args) {
    LinkedList < String > stkList = new LinkedList < > ();

    stkList.push("One");
    stkList.push("Two");
    stkList.push("Three");
    stkList.push("Four");

    System.out.println(stkList.pop());
    System.out.println(stkList.pop());
    System.out.println(stkList.pop());
    System.out.println(stkList.pop());

  }
}
Four
Three
Two
One

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment