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);

}

1 Answer 1

4

Just make sure the inner class constructor is public then:

A.W myW = new A.W(10, 1);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .