![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Nested interface in Java
We can declare an interface in another interface or class. Such an interface is termed as a nested interface.
The following are the rules governing a nested interface.
- A nested interface declared within an interface must be public.
- A nested interface declared within a class can have any access modifier.
- A nested interface is by default static.
Following is an example of a nested interface.
Example
class Animal { interface Activity { void move(); } } class Dog implements Animal.Activity { public void move() { System.out.println("Dogs can walk and run"); } } public class Tester { public static void main(String args[]) { Dog dog = new Dog(); dog.move(); } }
Output
Dogs can walk and run
Advertisements