wood burning stoves 2.0*
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

Win a copy of Spring in Action this week in the Spring forum!
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...

<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Please help me understanding this