0

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.

Tom Blodget
  • 20,260
  • 3
  • 39
  • 72
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
  • Marko Zadravec, when you select `New -> Class` there comes option for declaring `super class` and `interfaces`. just `browse/add` your classes/interfaces in relevant text boxes and you will get auto generated unimplemented methods – Shailesh Aswal Jul 18 '14 at 05:49

1 Answers1

1

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
    }
}
ccjmne
  • 9,333
  • 3
  • 47
  • 62