Create New Java Interface in Eclipse

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

Reach Eclipse New Interface section

After clicking Interface, a new dialog box will be visible, which is to create new Java Interface.

Create New Java Interface in Eclipse

The following options are provided while creating interface. You need to also select the package name, in which you want to add the interface,

Source Folder
Type a source or click Browse and select a source folder.

Package
Mention the package here, in which the Interface gets added. Go for this option or select the Enclosing Type option.

Enclosing type
Select a type here, to enclose the new interface. Select this or the Package option above.

Name
You need to type the name of the new interface here.

Modifiers
Select modifiers: public, private, protected, static, etc. You need to select one or more access modifiers for the new interface.

Extended Interfaces
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,

Creating new Java interface in Eclipse

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,

New Java Interface created in Eclipse

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.

Create New Java Class in Eclipse
Create New Enum in Eclipse
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create free tutorials for all.

No Comments

Post A Comment