Hi,
josh wrote:
> so if I had neither an interface and neither an abstract class
> could I do it?
>
> myFunction(
> new MyClass()
> {
>
> }
> )
Ah, perhaps you mean: There is no class or interface MyClass at all?
Then you could do this in a slightly different syntax:
myFunction(new Object(){});
You could even do the following:
myFunction(new Object(){
void foo() {
System.out.println("Hello World!");
}
});
The problem is: Of course, that only works, if the signature of
"myFunction" is "Object". And if that is the case, the function "foo"
can never be called, because the class Object itself has no method
foo(). (You could use reflection, but that is another question.)
So, the question remains the same: What is the signature of
myFunction()? Or differently asked: Why do you want to call a function
with an "undefined" (whatever that means) parameter?
Ciao,
Ingo
|