class から匿名メソッドを実行する方法。
例えば、
クラスがあります
Class A {
void Save(){
//do something
}
}
Class B {
void Save(){
//do something
}
}
どこかからオブジェクトを取得すると:
Object something = (could be A or B both because object can accept anything.)
something.Save() //doesn't work. To solve this I could use inheritance(abstract class or Interface) but if I want to do it anonymously
VBのように
object Form = SomeRandomForm
Form.Save() // anonymously no need to inherit
Javaで可能ですか?