0

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?

Gerd
  • 2,265
  • 1
  • 27
  • 46

3 Answers3

2

It's called anonymous class, more here : http://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html

Co_42
  • 1,169
  • 1
  • 10
  • 19
0

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.

Community
  • 1
  • 1
Scorpio
  • 2,309
  • 1
  • 27
  • 45
0

You can find it here, on JLS specifications.

Ioan
  • 5,152
  • 3
  • 31
  • 50