File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please help me understanding this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Please help me understanding this" Watch "Please help me understanding this" New topic

Please help me understanding this

Mani Sing

Joined: Jun 30, 2010
Posts: 7

public class Redwood extends Tree{
public static void main(String [] args){
new Redwood().go();
void go(){
go2(new Tree(),new Redwood());
go2((Redwood) new Tree(), new Redwood());
void go2(Tree t1, Redwood r1){
Redwood r2=(Redwood)t1;
Tree t2=(Tree)r1;
class Tree{}

I mean how the stack and heap will contain the different references as well as objects.

Will appreciate your help in this.

Sunny Bhandari
Ranch Hand

Joined: Dec 06, 2010
Posts: 448

Please use code tags and do ask more specific question.

I mean you must have got some idea what is stored in stack and what in heap!!

Java Experience
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
Objects created by new operator and global variables are stored in heap..

All local variables created inside methods are stored in stack...

My Techie Blog - Java Questions
I agree. Here's the link:
subject: Please help me understanding this
It's not a secret anymore!