Java.lang.Class.isSynthetic() Method


Advertisements


Description

The java.lang.Class.isSynthetic() 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

Example

The following example shows the usage of java.lang.Class.isSynthetic() method.

package com.tutorialspoint;

import java.lang.*;

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);        
   }
} 

Let us compile and run the above program, this will produce the following result −

It is a synthetic class ? false

java_lang_class.htm

Advertisements