
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Implement Interface Using Anonymous Inner Class in Java
An anonymous inner class is a class which doesn't have a name, we will directly define it at the instantiation line.
Example
In the following program, we are implementing the toString() method of TutorialsPoint interface using Anonymous inner class and, print its return value.
interface TutorialsPoint{ public String toString(); } public class Main implements TutorialsPoint { public static void main(String[] args) { System.out.print(new TutorialsPoint() { public String toString() { return "Welcome to Tutorials Point"; } }); } }
Output
Welcome to Tutorials Point
Advertisements