CptSupermrkt
Lurker
I have a mega stupid question, but I can't seem to find the right wording in Google to find the answer.
In several of the tutorials I've gone through, the following syntax is used:
1) What is this achieving? Is this allowing you to override one particular method for only THAT instance that you've just created, without needing to extend the entire class?
2) What is this syntax best called or described as? I tried Googling for stuff like, "declare method inside new instance" and such, and got nothing.
3) Are there any best practices/potholes that I should be aware of in using this? (e.g. "it's generally discouraged", etc.)
Thanks!
In several of the tutorials I've gone through, the following syntax is used:
Code:
Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
//do stuff
}
}
1) What is this achieving? Is this allowing you to override one particular method for only THAT instance that you've just created, without needing to extend the entire class?
2) What is this syntax best called or described as? I tried Googling for stuff like, "declare method inside new instance" and such, and got nothing.
3) Are there any best practices/potholes that I should be aware of in using this? (e.g. "it's generally discouraged", etc.)
Thanks!