java 根据类名示例化类_Java类类的requiredAssertionStatus()方法和示例
java 根據類名示例化類
類的類requiredAssertionStatus()方法 (Class class desiredAssertionStatus() method)
desiredAssertionStatus() method is available in java.lang package.
requiredAssertionStatus()方法在java.lang包中可用。
desiredAssertionStatus() method is used to return the desired assertion status of the given class when it was to be initialized at the time of this method is called.
當在調用此方法時要初始化給定類時,使用requiredAssertionStatus()方法返回給定類的所需斷言狀態。
desiredAssertionStatus() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
requiredAssertionStatus()方法是一種非靜態方法,僅可通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。
desiredAssertionStatus() method does not throw an exception at the time of getting desired assertion status.
所需的斷言狀態時, desiredAssertionStatus()方法不會引發異常。
Syntax:
句法:
public boolean desiredAssertionStatus();Parameter(s):
參數:
It does not accept any parameter.
它不接受任何參數。
Return value:
返回值:
The return type of this method is boolean, it returns true when desired assertion status is returned.
此方法的返回類型為boolean ,當返回所需的斷言狀態時,它返回true。
Example:
例:
// Java program to demonstrate the example // of boolean desiredAssertionStatus() method of Class public class DesiredAssertionStatusOfClass {public static void main(String[] args) {// Creating an instance of the classDesiredAssertionStatusOfClass assertion = new DesiredAssertionStatusOfClass();// Get Class by using getClass() methodClass cl = assertion.getClass();// Display this ClassSystem.out.println("Class: " + cl);// By using desiredAssertionStatus() method is to get the // status of this class DesiredAssertionStatusOfClassboolean assertion_status = cl.desiredAssertionStatus();// Display assertion status of the class System.out.println("Assertion Status: " + assertion_status);} }Output
輸出量
Class: class DesiredAssertionStatusOfClass Assertion Status: false翻譯自: https://www.includehelp.com/java/class-class-desiredassertionstatus-method-with-example.aspx
java 根據類名示例化類
總結
以上是生活随笔為你收集整理的java 根据类名示例化类_Java类类的requiredAssertionStatus()方法和示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: cad安装日志文件发生错误_苹果电脑Ma
- 下一篇: 2019聊大考研计算机调剂,2019年聊