0

My Scenario is that I need to call the inner class Constructor from another class, Let me know how can I achieve this.

Codes:

public class A {

    // Inner Class
    public class W {

        Integer y;
        String j;
        //Constructor
       W(Integer i, String g){
            this.y = i;
            this.j = j;

        }
    }

How can I access the Constructor W from another class B:

public class B {

    A a = new A();

    a.W.W(10,l);

}
3

Just make sure the inner class constructor is public then:

A.W myW = new A.W(10, 1);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.