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