Ein Stack (Kellerspeicher, Stapel) ist eine Datenstruktur, die nach dem LIFO-Prinzip (last-in-first-out) arbeitet
Daraus ergibt sich die folgende Ausgabe beim folgenden Beispiel:
- third element
- second element
- first element
StackExample.java
import java.util.*;
public class StackExample
{
public static void main
(String[] args
)
{
s.push("first elment");
s.push("second element");
s.push("third element");
while(true) {
try {
Out.println(s.pop());
break;
}
}
}
}