lundi 11 décembre 2017

Access class defined in method in Java

In Java, is it possible to access class defined in method by some means (reflections or so)? And How?

For example, i want to create instance of InnerClass in example below:

class Example {
    public void outerMethod() {
        class InnerClass {
            double d = 0;
        }
    }

    public void testMethod() {
        outerMethod::InnerClass instance = new outerMethod::InnerClass();
    }
}

Thanks for answers.





Aucun commentaire:

Enregistrer un commentaire