CJCoding With Joseph
15free / daySign inCreate account

Build the Array Stack Core

The two fields are declared but nothing sets them up, so a new stack is unusable. The given isEmpty(), isFull() and toString() show exactly how items and top are meant to behave - read them and make the rest agree.

Requirements:
1. In the constructor, give items room for MAX_SIZE values and set top to the value that means empty.
2. Write push(int) returning false when full and true otherwise, pop() and peek() returning -1 when empty, and size() returning how many values are stored.

Do NOT write a main method.

Expected Output:

true
0
true
true
true
Stack: 10 20 30
30
30
Stack: 10 20
2

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Data Structures & AlgorithmsStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.