This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes stacks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "stacks" Watch "stacks" New topic
Author

stacks

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
in my book they created a stack object like so..

Stack word = new Stack();

and they pushed and poped characters.

because the book didn't say that the Stack was a char Stack.

so you can push or pop any value in a stack?

and it doesn't matter?

so i could say

char A = a;
String string = hello;

word.push (A);
word.push (3);
word.push (string);

and i wouldn't get an error?

please clarify...

thanks

-Justin-


You down with OOP? Yeah you know me!
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
It shouldn't allow it, try and compile and run it.

Stack is not a stand alone data structure, it could be build on an array, linked list and in the case of Stack in the API it is built using Vector.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stacks