CJCoding With Joseph
15free / daySign inCreate account

Push a Value onto an Array Stack

An array-backed stack stores its values in an int array and keeps top as the index of the item currently on top. Every method is written except push.

Requirements:
1. Complete push(int value) so it moves top up one slot and stores value there.
2. Return false and change nothing when the stack is already full.
3. Return true after a value is stored.

Do NOT write a main method.

Expected Output:

true
true
true
Stack: 10 20 30
30

= 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.