15 Sep Create New Java Interface in Eclipse
Interface is a collection of abstract methods and is considered as a reference type in Java. Interface in Java are declared using the Interface keyword. We will learn how to create new Java Interface with Eclipse.
Launch Eclipse and then click the File Menu,
File > New > Interface
After clicking Interface, a new dialog box will be visible, which is to create new Java Interface.
The following options are provided while creating interface. You need to also select the package name, in which you want to add the interface,
Type a source or click Browse and select a source folder.
Mention the package here, in which the Interface gets added. Go for this option or select the Enclosing Type option.
Select a type here, to enclose the new interface. Select this or the Package option above.
You need to type the name of the new interface here.
Select modifiers: public, private, protected, static, etc. You need to select one or more access modifiers for the new interface.
Choose interfaces by clicking Add, which the new interface extends.
Do you want to add comments?
Select the option, if you want the comments to be added to the new class.
Demo Java Interface in Eclipse
For demo, we will be creating a new Interface inside the same project and package we created before. Go to File > New > Interface and fill the details for new Java Interface,
The name of our project is StudyopediaProject, which we created before. We added a new package in it i.e. com.studyopedia.
Now, we’re adding a new Java interface, with name Team. You can give any name to it.
After clicking Finish above, the Java Interface gets created successfully as shown below,
We have till now created project, package and class in Eclipse. The project name is StudyopediaApplication and the package is com.studyopedia. The class we added in this lesson is Products.
In the next lesson, we will learn how to create new Enum in Eclipse.