Is it possible to set a default behaviour for custom (non-native) methods/functions in Java?
Posted
by Tom
on Stack Overflow
See other posts from Stack Overflow
or by Tom
Published on 2010-05-10T22:10:29Z
Indexed on
2010/05/10
22:24 UTC
Read the original article
Hit count: 228
Is it possible to set a default behaviour for custom (non-native) methods/functions in Java?
For example, I would like to change the default "Function" to do a System.out.println("message")
whenever called.
So, when a custom method/function is being created:
public String testMethod()
{
//custom code
}
it should execute the newly added default behaviour (in this case the system output), before the custom code is run.
Even if this would be a bad excercise, is it possible? Maybe by extending the function class or something?
© Stack Overflow or respective owner