A class can implement more than one interfaces by separating the interfaces with commas ' , ' as shown below:
class ClassName implements Interface1, Interface2, Interface3
{
//Body of the class
}
Lets implement this on Eclipse IDE:
1. Create Interface 'Interface1' as shown below:
3. Create Interface 'Interface3' as shown below:
8. Observe that the output is displayed in the console as shown below:
Click here to download the project containing the 'Interface1', 'Interface2', 'Interface3', 'Interface4', 'ClassOne' and 'MultipleInterfacesDemo' files used in this post (You can download the project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
'Single Interface Implemented by Multiple Classes' will be explained in the next post.
No comments:
Post a Comment