Reputation: 1332
Actually here is me code
public class Example {
public void method () throws InterruptedException {
int var = 100;
Thread.sleep(5000);
// do some logic
}
}
I need to know is the local variable var
so incapsulated like wise people say.
Upvotes: 0
Views: 518
Reputation: 34563
Local variables only exist while the method is running, and there's a separate copy in each activation of the method. Since the reflection API doesn't reflect method activations, you can't get methods' local variables via reflection.
Upvotes: 3