16 lines
492 B
Plaintext
16 lines
492 B
Plaintext
import ballerina/io;
|
|
|
|
public function main() {
|
|
int[] stack = [];
|
|
stack.push(1);
|
|
stack.push(2);
|
|
io:println("Stack contains ", stack);
|
|
io:println("Number of elements in stack = ", stack.length());
|
|
int item = stack.pop();
|
|
io:println(item, " popped from the stack");
|
|
io:println("Last element is now ", stack[stack.length() - 1]);
|
|
stack.removeAll();
|
|
io:println("Stack cleared");
|
|
io:println("Is stack now empty? ", stack.length() == 0 ? "yes" : "no");
|
|
}
|