I saw these codes.
I’ve never seen such constructor, but I guess that it creates a new A instance with the implementation of a abstract method.
what is it called?
new A() {
@Override
public void onEvent() {
dosomething();
}
};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
are you referring to an anonymous class? Its when you provide an implementation but never define a named class. In other words, you are providing an object in-place; you cannot reuse that definition elsewhere because you never wrote
class MyClass {}, which is why it’s “anonymous”.See this.