简体   繁体   中英

Where do I find tech spec overload abstract method in Java constructor?

I try Apache Wicket. This framework override abstract methods in java constructor.

Example:

public abstract class BasePage extends WebPage {

...
this.add(new Link<Void>("logout") {
        @Override
        public void onClick() {
            ...
        }
    });
}

I know it is possible to declare Class A whith abstract method my_method and declare Class B extends Class A and define real code for abstract method my_method in class B.

But I don't know any mechanism in Java to override an abstract method in constructor dynamically like in wicket.

How call these Java technology and where I can find a detailed technical specification of it?

它被称为匿名类,更多信息来自: http//docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html

It's an anonymous inner class, basically an on-the-fly class for a special purpose that does not merit its own name or file. In some cases, you can see it quite often. This answer might shed more light on the topic. It also contains a link to the oracle specs.

您可以在JLS规范中找到它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM