Java.lang.Class.desiredAssertionStatus() Method
Advertisements
Description
The java.lang.Class.desiredAssertionStatus() method returns the assertion status that would be assigned to this class if it were to be initialized at the time this method is invoked.
Declaration
Following is the declaration for java.lang.Class.desiredAssertionStatus() method
public boolean desiredAssertionStatus()
Parameters
NA
Return Value
This method returns the desired assertion status of the specified class.
Exception
NA
Example
The following example shows the usage of java.lang.Class.desiredAssertionStatus() 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 the name of the class
String name = cls.getName();
System.out.println("Class Name = " + name);
// returns assertion status
boolean retval = cls.desiredAssertionStatus();
System.out.println("status = " + retval);
}
}
Let us compile and run the above program, this will produce the following result:
Class Name = ClassDemo status = false