What is a synthetic class in Java? Why should it be used? How can I use it?
What is a synthetic class in Java?
A synthetic class is a .class file generated by Java Compiler and it does not exist in the source code.
Example usage of synthetic class: Anonymous inner class
synthetic class and it is a anonymous inner class inside java.text.DigitListDigitList$1.java but it is a inner file in DigitList.javaWhy should it be used?
It is a mechanism inside Java compiler logic to generate the .class file
How can I use it?
No, developers do NOT use it directly.
Java compiler use synthetic to generate .class file, and then JVM reads the .class file to execute the program logic.
synthetic class in detailssynthetic class exits in JDK