This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Two notes: 1) you may want to check against stack.length - 1 instead of 9. That will cause less bugs should you wish to change the size of the array. 2) printing an error and returning 0 may not be a good option for real-life projects. Instead, throw a RuntimeException.
Please use code tags when posting code; it makes it easier to read. I have edited your post; see how much better it looks. And please write your question in the text of the post, otherwise people won't realise what the question is!!