
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
Create a Class Without a Name in Java
Yes, we can create a class without a name using the Anonymous class.
Anonymous class is an inner class which does not have a name and whose instance is created at the time of the creation of class itself and these classes are somewhat different from normal classes in its creation.
Example
public class Anonymous { public void show() {} public static void main(String args[]) { Anonymous a = new Anonymous() { public void show() { System.out.println("Anonymous Class"); } }; a.show(); } }
Output
Anonymous Class
Advertisements