• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stacks

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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-
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic