views:

23

answers:

0

Is it possible for me to print all the local, instance variable at runtime on demand. By on Demand I mean like we have jdb -attach <port> which we do at runtime and then we can start debugging... likewise I want to just print all those variables instead of debugging. is it possible?

For example as can be seen, MyDebuggerExample make a call to Example.trialAndError although there are no Logger/println statement I still wish to print values of i and j from 0 - 100?

class Example {
    public void trialAndError() {
        for (int i=0; i < 100; i++) {
            int j=i+2;          
        }
    }
}

public class MyDebuggerExample {
    public static void main(String[] args) {
        new Example().trialAndError(); //is it possible to print i and j from 0-99? 
    }
}

Ideas? Suggestions?