/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
private static int runningLoop;
static{
str = "Static Block";
}
/**
* Non-Static Method Accessing Static Member
*/
public void modifyStaticMember(){
str = "Non-Static Method";
}
/**
* Non-Static Method invoking Static Method
*/
public void invokeStaticMethod(){
if(runningLoop == 0){
runningLoop++;
main(args);
}
//Exiting as it will lead to java.lang.StackOverflowError
}
public static void main
(String[] args
) {
Ideone instance = new Ideone();
instance.modifyStaticMember();
// Changed Value persists
//Invoking Static Method
instance.invokeStaticMethod();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCQoJcHJvdGVjdGVkIHN0YXRpYyBTdHJpbmcgc3RyOwoJcHJpdmF0ZSBzdGF0aWMgaW50IHJ1bm5pbmdMb29wOwoJCQoJc3RhdGljewoJCXN0ciA9ICJTdGF0aWMgQmxvY2siOwoJfQoJCgkvKioKCSAqIE5vbi1TdGF0aWMgTWV0aG9kIEFjY2Vzc2luZyBTdGF0aWMgTWVtYmVyICAKCSAqLwoJcHVibGljIHZvaWQgbW9kaWZ5U3RhdGljTWVtYmVyKCl7CgkJc3RyID0gIk5vbi1TdGF0aWMgTWV0aG9kIjsJCQoJfQoKCS8qKgoJICogTm9uLVN0YXRpYyBNZXRob2QgaW52b2tpbmcgU3RhdGljIE1ldGhvZAoJICovCglwdWJsaWMgdm9pZCBpbnZva2VTdGF0aWNNZXRob2QoKXsKCQlTdHJpbmdbXSBhcmdzID0ge307CgkJaWYocnVubmluZ0xvb3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