File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "stacks" Watch "stacks" New topic


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...



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:
subject: stacks
jQuery in Action, 3rd edition