• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

how do you add strings(java)?

Semidevil

Diamond Member
so lets say I created a stack, and I want to add strings to them...how do I do that?


all I did so far is create the stack, like

Stack stack2 = new Stack();

so after I create my stacks what do I do in the next couple of lines?, how do I add strings to it?
 
so...just to clarify...

you're asking how to add strings to a stack?

:evil:

sorry...i couldnt resist 😛
 
stack2.push(string)

For some reason I can't remember if push is a stack or a queue thing.. I take it you didn't develop the classes for the stack yoursef, but instead you're using the included crappy ones in the java api?
 
Stack stack = new Stack();
stack.push("java");
stack.push("teh");
stack.push("at");
stack.push("suck");
stack.push("you");

while(!stack.empty()) System.out.print(stack.pop() + " ");
 
Back
Top