Generating Interface from a Class
by , 11-14-2011 at 05:27 PM (523 Views)
Some times you have a class with concrete methods and you want to declare an interface with all the methods in the class. You may call it backtracking. In this post, I will write about how to do this in Eclipse.
Suppose we have a class called Students that has methods defined in it. We want to generate the interface for it in Eclipse. Simply right click the class name, or simply right click anywhere in the code and select Refactor > Extract interface. A new window will open. Name the interface and select the methods you want to put into the interface. All the methods in the Students class will be listed in the window and by default none will be selected. After naming and selecting the methods, you can get the preview as well or simply click ok to generate the interface.
The signature of Student class will also change to:
This approach is a backtracking approach and generates the interface in no time. Try it.Java Code:public class Students implements StInterface { … }









Email Blog Entry
Size Reduced for Images in PDF &...
05-15-2013, 05:53 PM in Java Software