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


public class A {

    // Inner Class
    public class W {

        Integer y;
        String j;
       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();



1 Answer 1


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 .