/
githubmirror
/
hello-algo
Обзор
Документация
Войти
/
githubmirror
/
hello-algo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
en/codes/java/chapter_stack_and_queue/stack.java
40 строк
1 KB
Yudong Jin
Translate all code to English (#1836)
31 дек 2025, 02:44
Не верифицирован
31 дек 2025, 02:44
2778a6f
Код
Авторство
О чём код?
/** * File: stack.java * Created Time: 2022-11-25 * Author: krahets (krahets@163.com) */ package chapter_stack_and_queue; import java.util.*; public class stack { public static void main(String[] args) { /* Access top of the stack element */ Stack<Integer> stack = new Stack<>(); /* Elements push onto stack */ stack.push(1); stack.push(3); stack.push(2); stack.push(5); stack.push(4); System.out.println("Stack stack = " + stack); /* Return list for printing */ int peek = stack.peek(); System.out.println("Stack top element peek = " + peek); /* Element pop from stack */ int pop = stack.pop(); System.out.println("Pop element pop = " + pop + ", after pop, stack = " + stack); /* Get the length of the stack */ int size = stack.size(); System.out.println("Stack length size = " + size); /* Check if empty */ boolean isEmpty = stack.isEmpty(); System.out.println("Stack is empty = " + isEmpty); } }