mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-10 16:00:36 +08:00
Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese * Polish three English explanations after reader-focused review
This commit is contained in:
@@ -10,10 +10,10 @@ import java.util.*;
|
||||
|
||||
public class stack {
|
||||
public static void main(String[] args) {
|
||||
/* Access top of the stack element */
|
||||
/* Initialize the stack */
|
||||
Stack<Integer> stack = new Stack<>();
|
||||
|
||||
/* Elements push onto stack */
|
||||
/* Push elements onto the stack */
|
||||
stack.push(1);
|
||||
stack.push(3);
|
||||
stack.push(2);
|
||||
@@ -21,20 +21,20 @@ public class stack {
|
||||
stack.push(4);
|
||||
System.out.println("Stack stack = " + stack);
|
||||
|
||||
/* Return list for printing */
|
||||
/* Access the top element */
|
||||
int peek = stack.peek();
|
||||
System.out.println("Stack top element peek = " + peek);
|
||||
System.out.println("Top element peek = " + peek);
|
||||
|
||||
/* Element pop from stack */
|
||||
/* Pop an element from the stack */
|
||||
int pop = stack.pop();
|
||||
System.out.println("Pop element pop = " + pop + ", after pop, stack = " + stack);
|
||||
System.out.println("Popped element pop = " + pop + ", after popping, stack = " + stack);
|
||||
|
||||
/* Get the length of the stack */
|
||||
/* Get the stack size */
|
||||
int size = stack.size();
|
||||
System.out.println("Stack length size = " + size);
|
||||
System.out.println("Stack size = " + size);
|
||||
|
||||
/* Check if empty */
|
||||
/* Check whether it is empty */
|
||||
boolean isEmpty = stack.isEmpty();
|
||||
System.out.println("Stack is empty = " + isEmpty);
|
||||
System.out.println("Is the stack empty = " + isEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user