This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Object on stack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Object on stack" Watch "Object on stack" New topic
Author

Object on stack

Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
Hi,
How to put an object on stack in java?
Rgds,
Seetesh
Annekee Dufour
Ranch Hand

Joined: Nov 04, 2003
Posts: 41
why would you want to do that?
Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
Hi,
Just checking out the possiblity if its possible?
Seetesh
Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
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

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Annekee Dufour
Ranch Hand

Joined: Nov 04, 2003
Posts: 41
Aha, you mean a Stack and not the stack as in stack vs. heap!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object on stack
 
Similar Threads
Can we access an object that is not on top of value stack from jsp page
new class from old class
Where do Variables live?
Stack n Heap
WA #1.....word association