
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Is it possible to 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
- Related Articles
- Is it possible to create a custom exception in java without extending Exception class?
- Is it possible to override a Java method of one class in same?
- Is it possible to create static constructor in java?
- Is it possible to throw exception without using "throws Exception" in java?
- How to access the object of a class without using the class name from a static context in java?
- Is it possible to create a new data type in JavaScript?
- Is it possible to use pyplot without DISPLAY?
- Is it possible to assign a reference to "this" in java?
- What is the difference between simple name, canonical name and class name in a Java class?
- Check if it is possible to create a polygon with a given angle in Python
- Is it possible to assign a numeric value to an enum in Java?
- Create Objects of a Class in Java
- Is it possible for human beings to live without any goals?
- Is It Possible to Do Digital Marketing Without Social Media Marketing?
- Is it possible to check if a String only contains ASCII in java?

Advertisements