Search code examples
javarecursionscoping

Dynamically scoped variable in java ? (a.k.a one variable per method execution)


I would like to know if it's possible in java to declare a variable local to the execution of the method.

For instance, if i'm doing some recursive stuff and i want to keep various counters specific to one particular execution of the method.

I don't know the correct english expression for that...


Solution

  • void method()
    {
         int i = 0;  // this int is local to 'method'
    }