Reputation: 1
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++}
}
}
Upvotes: 0
Views: 68
Reputation: 3881
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));
}
}
Upvotes: 1