Home »
Java programming language
Java System class inheritedChannel() method with example
System class inheritedChannel() method: Here, we are going to learn about the inheritedChannel() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 14, 2019
System class inheritedChannel() method
- inheritedChannel() method is available in java.lang package.
- inheritedChannel() method is used to return the channel inherited from the entity that generated current JVM (Java Virtual Machine).
- inheritedChannel() method is a static method so this method is accessible with the class name too.
-
inheritedChannel() method may throw a various exception and the description of the exception is given below:
- IOException: In this exception, the exception will be thrown related to input/output error.
- SecurityException: In this exception, it does not allow access to the Channel when security manager exists.
Syntax:
public static Channel inheritedChannel() throws IOException{
}
Parameter(s):
- It does not accept anything.
Return value:
The return type of this method is Channel, it returns the inherited channel if channel is inherited, else it returns the null.
Example:
// Java program to demonstrate the example of
// inheritedChannel () method of System Class
public class InheritedChannelMethod {
public static void main(String[] args) {
try {
System.out.println("Inherited Channel: " + System.inheritedChannel());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
Output
E:\Programs>javac InheritedChannelMethod.java
E:\Programs>java InheritedChannelMethod
Inherited Channel: null