如何增加堆叠容量? [英] How to increase the capacity of a stack?
问题描述
我在Java中使用 Stack
。问题是我只能将10个项目推入堆栈,而我又需要推20个项目。
I'm using a Stack
in Java. The problem is that I only can push 10 items into the stack, and I need to push 20 items.
如何增加堆栈的容量?
推荐答案
Java的 Stack
类继承自 Vector
,并提供方便的方法以允许 Vector
像堆栈一样工作。由于 Vector
自然增长,因此无需手动增加容量。
Java's Stack
class inherits from Vector
and provides convenience methods to allow a Vector
to behave like a stack. Since Vector
grows naturally, there's no need to increase the capacity manually.
我猜你在做什么还有其他问题。那,或者我误解了你的问题。如果您想获得更准确的答案,请提供更多信息,例如您使用的代码,您期望的行为,所获得的行为等。
I'm guessing you're doing something else wrong. That, or I misunderstood your question. If you want a more accurate answer, please give more information, such as the code your using, what behavior are you expecting, what behavior are you getting, etc.
这篇关于如何增加堆叠容量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!