Java PropertyPermission newPermissionCollection()方法与示例
PropertyPermission類newPermissionCollection()方法 (PropertyPermission Class newPermissionCollection() method)
newPermissionCollection() method is available in java.util package.
newPermissionCollection()方法在java.util包中可用。
newPermissionCollection() method is used to create a new PermissionCollection object.
newPermissionCollection()方法用于創建新的PermissionCollection對象。
newPermissionCollection() 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.
newPermissionCollection()方法是一個非靜態方法,只能通過類對象訪問,如果嘗試使用類名訪問該方法,則會收到錯誤消息。
newPermissionCollection() method does not throw an exception at the time of creating an object.
newPermissionCollection()方法在創建對象時不會引發異常。
Syntax:
句法:
public PermissionCollection newPermissionCollection();Parameter(s):
參數:
It does not accept any parameter.
它不接受任何參數。
Return value:
返回值:
The return type of the method is PermissionCollection, it returns new PermissionCollection object.
該方法的返回類型為PermissionCollection ,它返回新的PermissionCollection對象。
Example:
例:
// Java program to demonstrate the example // of newPermissionCollection() method of // PropertyPermissionimport java.util.*; import java.security.*;public class NewPermissionCollectionOfPropertyPermission {public static void main(String arg[]) {// Instantiates two PropertyPermission objectPropertyPermission prop_perm1 = new PropertyPermission("os.version", "write");PropertyPermission prop_perm2 = new PropertyPermission("os.name", "read");// By using newPermissionCollection() method// is to create a new permission collection// and add permissionsPermissionCollection pc = prop_perm1.newPermissionCollection();pc.add(prop_perm1);pc.add(prop_perm2);// By using implies() method isto// check whether this PermissionCollection// holds the permission write or notboolean status = pc.implies(prop_perm1);// Display statusSystem.out.print("pc.implies(prop_perm1): ");System.out.println(status);} }Output
輸出量
pc.implies(prop_perm1): true翻譯自: https://www.includehelp.com/java/propertypermission-newpermissioncollection-method-with-example.aspx
總結
以上是生活随笔為你收集整理的Java PropertyPermission newPermissionCollection()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 眼镜框一般多少钱啊?
- 下一篇: 长虹电视是那里生产的?