This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Regarding stack, could anybody suggest me that how to do the following: I give the size of stack from command line and i have to use this size so that an stack can automatically and increase when stack overflow occurs. Thanks Rashid
Someone please correct me if I'm wrong, as I haven't used stacks before, but my understanding of them was that they're growable and hence, in Java, it isn't possible to get a stack overflow. It automatically increases on it's own. (It extends Vector).
Joined: Jan 16, 2001
Thanks for your answer. So it means that i don't need to set the size of stack whenever i want i can add the items in stack and it will automatically increase its length and there is no need to afraid of stack overflow. But if i want to give its initial length so how could i give it in stack. Please suggest.
Joined: Jul 08, 2001
There are various methods that allow you to play with the size. you can find the java API here: http://java.sun.com/j2se/1.3/docs/api/index.html. The lower window on the left side lists every class in J2SE. Scroll down to stacks and it will show you all of it's methods and, more importantly (for what you want), those it inherits from Vector.
You two are talking about different things. A Stack is an ADT that java implements in the class Stack. The Stack is where java stores all its objects. The Stack can overflow. Don't worry about it, it is mostly unrecoverable.