简体   繁体   中英

Create auto generated methods in your class in eclipse

I am writing some classes in Eclipse in Java, and I would like to know how to generate auto generate code.

For example, if I have abstract class and I expect to be use as extends class I would like to force override some classes.

I see that same classes has this implemented, and if you extend from them eclipse auto generate empty methods for override.

Assuming you have such classes:

public abstract class A {
    public void implementMe();
}

... and:

public class B extends A {
}

In Eclipse , just hit Ctrl 1 on the name of class that needs to override some methods and select "Add unimplemented methods" in the contextual menu that will show up.

// Ctrl - 1 with your cursor here
//           v    
public class B extends A {
}

It will generate for you the following:

public class B extends A {

    @Override
    public void implementMe() {
        // TODO Auto-generated method stub
    }
}

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