Ok, im an idiot.

Basically I am a class A idiot, ive left more coursework right to the last minute and Im hoplessly lost and confused about this question :

2: Tracing the Execution Stack

class Something

{

private int n;

public Something(int n)

{

this.n = n;

}

public void grow(int d)

{

this.n += d;

}

public boolean isNegative()

{

return (this.n < 0);

}

public String toString()

{

return ("something(" + this.n + ")");

}

}

public class ExecutionStackDemo

{

private static void m2(Something sth)

{

int i = 3;

sth.grow(2 * i);

i = 4711;

if (sth.isNegative())

{

sth.grow(i);

}

}

public static void main(String[] args)

{

int i = -2;

Something s = new Something(i);

m2(s);

}

}

For the code above, give an account of the evolution of the execution stack. Determine the sequence of invocations

of methods and constructors of the and the corresponding returns to the respective callers. Display the execution

stack after each time a new activation frame is created.

Basically put it all into netbeans, debugs and runs fine. My question is, what is an activation fram and how do I see them?

Anyhelp would be massively welcomed :)

Dave

[1394 byte] By [herghostuka] at [2007-11-26 19:12:43]
# 1
ok, you are an idiot.
mkoryaka at 2007-7-9 21:11:29 > top of Java-index,Java Essentials,New To Java...
# 2

I would assume by "activation frame" he means what I usually call a "stack frame."

You know what a stack is?

You know that the call stack is? It's a stack that holds the local variables, return value, etc. for each method called.

Here's a simplified view:

currentMethodVar1

currentMethodVar2

callerVar1

callerVar2

callerVar3

callersCallerVar1

A stack frame (or activation frame, I guess) is a single method's context--its locals, parameters, etc.

Your IDE's debugger should let you set breakpoints or step through the code a line at a time. When you do that, you can see the current stack frame (and possibly the calling methods' frames). See the IDE's docs for details.

jverda at 2007-7-9 21:11:29 > top of Java-index,Java Essentials,New To Java...
# 3
Thanks, thats what I was after, i called them stack frames too. Cheers jverd
herghostuka at 2007-7-9 21:11:29 > top of Java-index,Java Essentials,New To Java...