Home » Java programming language

Java Package isSealed() method with example

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

Package Class isSealed() method

  • isSealed() method is available in java.lang package.
  • isSealed() method is used to check whether this package is sealed or not sealed.
  • isSealed() 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.
  • isSealed() method does not throw an exception at the time of the sealing package.

Syntax:

    public boolean isSealed();

Parameter(s):

  • It does not accept any parameter.

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.
  • It returns false when this package is not sealed.

Example:

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

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

        // By using isSealed() method is to check 
        //whether this package is sealed or not
        boolean seal_status = pkg.isSealed();

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

Output

pkg.isSealed() = true


Comments and Discussions!

Load comments ↻





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