Q:

How can I use an inner class instance from another inner class method?

public class Ex7 {
    private int fld;

    private void meth(int val) {
        fld = val;
        System.out.println(" meth() -> fld = " + fld);
    }

    public class Ex7Inner1 {
        void operateOnFld() {
            fld = 12;
        }

        void operateOnMeth() {
            meth(10);
        }

        public void bar() {
            System.out.println(" bar() ");
        }
    }

    class Ex7Inner2 {
        Ex7Inner1 i1 = new Ex7Inner1();
        // how to call i1.bar() ??
        i1.bar();
    }
}

A:

Your problem is that you need to call i1.bar() inside a function.  For example
class Ex7Inner2 {
    Ex7Inner1 i1 = new Ex7Inner1();  // this is now a field of the Ex7Inner2 class
    public void callBar() {
        i1.bar();                    // this will work
    }
}

In the future, you may find that people are able to be more helpful if you include the error you get in your question, which I'll do now.  When you try to compile the code your way, you get an error that looks like
Ex7.java:26: <identifier> expected
  i1.bar();
        ^
1 error

This is because the only thing you can do outside of a method (like you originally had it) is declare variables.  So it was expecting an "identifier" by which it meant "the name of the variable you are declaring".  So if you had said
String s;

then s would have been the identifier.

