I just decompiled some java code and found something like that
public class Example {
private static String test(String s) {
String[] test = new String[1];
ExampleObject exampleObject = new ExampleObject() {
public void testMethod1() {
Example.this[0] = "1";//what's that?
}
public void testMethod2() {
Example.this[0] = "2";//what's that?
}
};
//some code with exampleObject and s
return test[0];
}
}
I don't want to post the original decompiled code, because I don't know if I am allowed to. But this is in principle the same code. There are no super classes and no fields in the original decompiled code.
I know that I can do Example.this
to access the fields and methods of the current instance of Example
. But I have never seen a code like Example.this[0]
. Also String[] test
is not a field of Example
, it's a variable in the private static String test(String s)
method. I tried to compile that code with eclipse, but I get errors.
Edit: The question is what does that code do? Or is it a bug of the decompiler?