java system类

系统类getSecurityManager()方法 (System class getSecurityManager() method)

  • getSecurityManager() method is available in java.lang package.

    getSecurityManager()方法在java.lang包中可用。

  • getSecurityManager() method is used to return the security manager if exists else it returns null if the security manager couldn't establish for the current application.

    getSecurityManager()方法用于返回安全管理器(如果存在),否则,如果安全管理器无法为当前应用程序建立,则返回null。

  • getSecurityManager() method is a static method so this method is accessible with the class name too.

    getSecurityManager()方法是静态方法,因此也可以使用类名访问此方法。

  • The return type of this method is SecurityManager so it returns the security manager only when a security manager is currently established for the current interface and it returns null when a security manager is not establishing for the current application.

    此方法的返回类型为SecurityManager,因此仅在当前为当前接口建立安全管理器时才返回安全管理器,而在没有为当前应用程序建立安全管理器时返回null。

  • getSecurityManager() method does not throw any exception.

    getSecurityManager()方法不会引发任何异常。

Syntax:

句法:

    public static SecurityManager getSecurityManager();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is SecurityManager, it returns the security manager only when a security manager is currently established for the current interface and it returns null when the security manager is not establishing for the current application.

此方法的返回类型为SecurityManager ,仅在当前为当前接口建立安全管理器时才返回安全管理器,而在没有为当前应用程序建立安全管理器时返回null。

Example:

例:

// Java program to demonstrate the example of
// getSecurityManager () method of System Class

import java.lang.*;

public class GetSecurityManagerMethod {
    public static void main(String[] args) {

        SecurityManager smgr = System.getSecurityManager();

        if (smgr != null) {
            smgr.checkExit(0);
        } else {

            System.out.println("Security manager is null");
        }

    }
}

Output

输出量

E:\Programs>javac GetSecurityManagerMethod.java
E:\Programs>java GetSecurityManagerMethod
Security manager is null


翻译自: https://www.includehelp.com/java/system-class-getsecuritymanager-method-with-example.aspx

java system类

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐