Pages

Friday, September 19, 2025

Java Collection Framework - Stack in Java

 import java.util.*;

// Java Collection Framework of Stack

class StackB {

    public static void main(String[] args) {

        Stack<Integer> s = new Stack<>();

        s.push(1);

        s.push(2);

        s.push(3);

        

        System.out.println(s); // Before pop

        

        while(!s.isEmpty()) {

            System.out.println(s.peek());

            s.pop();

        } 

        

        System.out.println(s);  // After pop 

    }

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...