Yes, we can use anonymous classes to create a class without a name.
Anonymous classes are inner classes without a name, instances of which are created when the class itself is created. These classes are created somewhat differently than normal classes.
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(); } }
Anonymous Class
The above is the detailed content of Is it possible to create a class without a name in Java?. For more information, please follow other related articles on the PHP Chinese website!