Build the Array Stack Core
mediumQuestion 434The 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.