- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java Class isSynthetic() Method
Description
The Java Class isSynthetic() method returns true if this class is a synthetic class, else returns false.
Declaration
Following is the declaration for java.lang.Class.isSynthetic() method
public boolean isSynthetic()
Parameters
NA
Return Value
This method returns true if and only if this class is a synthetic class as defined by the Java Language Specification.
Exception
NA
Checking a Class to be Synthetic Example
The following example shows the usage of java.lang.Class.isSynthetic() method. In this program, we've created an instance of ClassDemo and then using getClass() method, the class of the instance is retrieved and using isSynthetic() method, we've checked the status and result is printed.
package com.tutorialspoint; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = c.getClass(); // returns true if this class is a synthetic class, else false boolean retval = cls.isSynthetic(); System.out.println("It is a synthetic class ? " + retval); } }
Output
Let us compile and run the above program, this will produce the following result −
It is a synthetic class ? false
Checking an ArrayList to be Synthetic Example
The following example shows the usage of java.lang.Class.isSynthetic() method. In this program, we've used class of ArrayList and using isSynthetic() method, we've checked the status and result is printed.
package com.tutorialspoint; import java.util.ArrayList; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = ArrayList.class; // returns true if this class is a synthetic class, else false boolean retval = cls.isSynthetic(); System.out.println("It is a synthetic class ? " + retval); } }
Output
Let us compile and run the above program, this will produce the following result −
It is a synthetic class ? false
Checking a Thread to be Synthetic Example
The following example shows the usage of java.lang.Class.isSynthetic() method. In this program, we've used class of Thread and using isSynthetic() method, we've checked the status and result is printed.
package com.tutorialspoint; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = Thread.class; // returns true if this class is a synthetic class, else false boolean retval = cls.isSynthetic(); System.out.println("It is a synthetic class ? " + retval); } }
Output
Let us compile and run the above program, this will produce the following result −
It is a synthetic class ? false