referencing method in the inner class from the outer class

i have the below code, and despite the classes and the memeber methods are public i couldnt reference methodHF not methodBF inside the methodLMF. i tried the following:

LMF.this.xxxx //but the methods do not show up

please tell me how to fix it.

code:

class LMF {
    LMF() {}

    public methodLMF() { } // should return methodHF+methodBF

    //class HF
    class HF {
        HF() {}

        public methodHF(int x) {x++}
    }

    //class BF
    class BF {
        BF() {}

        public methodBF(int x) {x++}
    }
}

Answers


You need to create Objects of HF and BF in order to access there method.

class LMF {
    LMF() {
    }

    public int methodLMF(int x) {
        return new HF().methodHF(x) + new BF().methodBF(x);
    } // should return methodHF+methodBF

    // class HF
    class HF {
        HF() {
        }

        public int methodHF(int x) {
            return x++;
        }
    }

    // class BF
    class BF {
        BF() {
        }

        public int methodBF(int x) {
            return x++;
        }
    }

    public static void main(String[] args) {
        System.out.println(new LMF().methodLMF(1));
    }
}

You need to access it as

HF hF = this.new HF(); hF.methodHF()


Need Your Help

Odoo: ValueError: Invalid field 'user_id' in leaf

python openerp

I am trying to create rule, to limit users to see only their records in tree view in my module, but it gives me error that 'user_id' field doesn't exist...

How to post message to wall (Android + FBConnect)

android facebook

I need to post message to a wall using FBConnect library for Android. How to do this?