Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stacks size

 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lucas Richardson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lucas Richardson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic