• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object on stack

 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How to put an object on stack in java?
Rgds,
Seetesh
 
Annekee Dufour
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why would you want to do that?
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just checking out the possiblity if its possible?
Seetesh
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was trying something like this
String language = "english";
String country = "english";
int a = 100;
int b= 100;
Stack astack = new Stack();
astack.push(language);
Stacks dont seem to take in int values.
Any clues.
Seetesh
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, they only hold Objects. In order to push ints or other built-in types onto a stack, you need to use the wrapper classes such as Integer. You should learn as much as you can about the wrapper classes. They are used quite frequently. I'm sure you can search the board for previous discussions about them.
Layne
 
Annekee Dufour
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha, you mean a Stack and not the stack as in stack vs. heap!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic