Is it possible to access the getVal() function inside displayMsg () function? I tried to create an annonymous inner-class with function getVal() and I want to call the getVal() function inside the displayMsg() function of the AnonymousClass.
import java.io.*;
class AnonymousClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
displayMsg(new AnonymouseEx(10){
public int getVal(){
return getValue();
}
});
}
static void displayMsg(AnonymouseEx obj)
{
}
}
class AnonymouseEx{
private int i=0;
AnonymouseEx(int val)
{
i = val;
}
int getValue()
{
return i;
}
}