Constructor isSynthetic() method in Java with Examples Last Updated : 29 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The isSynthetic() method of java.lang.reflect.Constructor class is used to return the boolean value true if this constructor object is a synthetic construct else method returns false showing this construct is not a synthetic construct. As we know Synthetic Constructs are Class, Fields, and Methods that are created by the Java compiler for internal purposes. In the case of Constructor, the synthetic construct is the constructor created by java compiler for internal uses. This method is helpful for identifying those constructs. Syntax: public boolean isSynthetic() Parameters: This method accepts nothing. Return: This method returns true if and only if this executable is a synthetic construct as defined by The Java Language Specification. Below programs illustrate isSynthetic() method: Program 1: Java // Java program to illustrate isSynthetic() method import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) { // create a class object Class classObj = shape.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); // check isSynthetic or not boolean answer = cons[0].isSynthetic(); // print result System.out.println("isSynthetic : " + answer); } @CustomAnnotation(createValues = "GFG") public class shape { @CustomAnnotation(createValues = "GFG") public shape() { } } // create a custom annotation public @interface CustomAnnotation { public String createValues(); } } Output: isSynthetic : false Program 2: Java // Java program to illustrate isSynthetic() method import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) { // create a class object Class classObj = String.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); for (int i = 0; i < cons.length; i++) { System.out.println("Constructor: " + cons[i]); // get array of isSynthetic boolean answer = cons[0].isSynthetic(); // print result System.out.println("isSynthetic : " + answer); } } } Output: Constructor: public java.lang.String(byte[], int, int) isSynthetic : false Constructor: public java.lang.String(byte[], java.nio.charset.Charset) isSynthetic : false Constructor: public java.lang.String(byte[], java.lang.String) throws java.io.UnsupportedEncodingException isSynthetic : false Constructor: public java.lang.String(byte[], int, int, java.nio.charset.Charset) isSynthetic : false Constructor: public java.lang.String(byte[], int, int, java.lang.String) throws java.io.UnsupportedEncodingException isSynthetic : false Constructor: public java.lang.String(java.lang.StringBuilder) isSynthetic : false Constructor: public java.lang.String(java.lang.StringBuffer) isSynthetic : false Constructor: public java.lang.String(byte[]) isSynthetic : false Constructor: public java.lang.String(int[], int, int) isSynthetic : false Constructor: public java.lang.String() isSynthetic : false Constructor: public java.lang.String(char[]) isSynthetic : false Constructor: public java.lang.String(java.lang.String) isSynthetic : false Constructor: public java.lang.String(char[], int, int) isSynthetic : false Constructor: public java.lang.String(byte[], int) isSynthetic : false Constructor: public java.lang.String(byte[], int, int, int) isSynthetic : false References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#isSynthetic() Comment More infoAdvertise with us Next Article Constructor isSynthetic() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Constructors Java-Functions java-lang-reflect-package Practice Tags : Java Similar Reads Class isSynthetic() method in Java with Examples The isSynthetic() method of java.lang.Class class is used to check if this Class is the Synthetic class. The method returns true if this Class is the Synthetic class. It returns false otherwise.Syntax: public boolean isSynthetic() Parameter: This method does not accept any parameter.Return Value: Th 2 min read Field isSynthetic() method in Java with Examples The isSynthetic() method of java.lang.reflect.Field is used to check whether Field Object is a synthetic field or not. If the field is a synthetic field then the function returns true otherwise it will return false. Synthetic Construct: Synthetic Construct is Class, Fields, and Methods that are crea 2 min read Constructor equals() method in Java with Examples The constructor class provides information about a single constructor for a class and it also provides access to that constructor. The equals() method of java.lang.reflect.Constructor is used to compare this Constructor against the passed object. If the objects are the same then the method returns t 2 min read Calendar isSet() Method in Java with Examples The isSet(int calndr_field) method in Calendar class is used to check whether the given calendar field has a value set or not. All the Cases for which the values have been set by the calculations of the internal field are triggered by a get method call. Syntax: public final boolean isSet(int calndr_ 2 min read ChronoPeriod isNegative() method in Java with Examples The isNegative() method of ChronoPeriod class in Java is used to check whether any of the three YEAR, MONTH, DAYS in period is negative or not. Syntax: boolean isNegative() Parameters: This method does not accepts any parameter. Return Value: This method returns True if any of the three-valued YEARs 2 min read Like