Home » Java programming language

Java Package isSealed(URL) method with example

Package Class isSealed(URL) method: Here, we are going to learn about the isSealed(URL) method of Package Class with its syntax and example.
Submitted by Preeti Jain, on December 04, 2019

Package Class isSealed(URL) method

  • isSealed(URL) method is available in java.lang package.
  • isSealed(URL) method is used to check whether this package is sealed or not sealed with respect to the given parameter src_code_url(source code url).
  • isSealed(URL) method is a non-static method, it is accessible with class object only and if we try to access the method with class name then we will get an error.
  • isSealed(URL) method does not throw an exception at the time of sealing package.

Syntax:

    public boolean isSealed(URL src_code_url);

Parameter(s):

  • URL src_code_url – represents the source code URL.

Return value:

The return type of this method is boolean, it returns the following values based on the given cases,

  • It returns true when this package is sealed with respect to the given source code URL.
  • It returns false when this package is not sealed with respect to the given source code URL.

Example:

// Java program to demonstrate the example 
// of boolean isSealed(URL src_code_url)
// method of Package 

import java.net.*;

public class IsSealed {
    public static void main(String[] args) throws Exception {
        // Get Package by using getPackage() method
        Package pkg = Package.getPackage("java.util");

        // By using isSealed(URL) method is to check 
        // whether this package is sealed or not by
        // the given URL
        URL seal_status = new URL("https://www.includehelp.com");

        // Display sealed status of the package
        System.out.println("pkg.isSealed(seal_status) = " + pkg.isSealed(seal_status));
    }
}

Output

pkg.isSealed(seal_status) = false


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.