I have a static function that takes an X parameter.
In this static function, I create an anonymous class. This class must have a member variable, also called X.
From functions in an anonymous class, how can I access the parameter of function X?
To illustrate:
class Test {
static void func(final List<T> X) {
new Test() {
final T[] X = ?.X.toArray();
};
}
}
In my real code, I want to create an array in my anonymous class from a list argument (through toArray()
in the initialization of an anonymous class), and I want to reuse the same variable name, and not use the Hungarian notation to differentiate them.
source
share