Help me to understand this
please explain whats going on this code..how to draw stack and heap diagram of this code
Code :
class A {
int i = 34;
static A m(A a) {
System.out.println(a.i);
a.i++;
a = new A();
System.out.println(a.i);
return a;
}
public static void main(String[] args) {
A a = new A();
m(a);
System.out.println(a.i);
A a1 = m(a);
System.out.println(a.i);
}
}
please help..
Re: Help me to understand this
Please post the print out from the program with your questions about what it generates.
Add a unique id to all 4 print statements so you can see which print statement it came from.
For example: System.out.println("1=" + a.i);
Re: Help me to understand this
Quote:
Originally Posted by
Norm
Please post the print out from the program with your questions about what it generates.
Add a unique id to all 4 print statements so you can see which print statement it came from.
For example: System.out.println("1=" + a.i);
thank you Norm, Now i can understand whats going on.