The Java error stream is used to print error that arises during the execution
of a program. The execution of program display an output and error to the
different stream that allows the user to move them to different pages thereby
isolating them. The output stream is used for command output, that is used to
print the output of a command to a user.
Understand with Example
In this Tutorial we want to describe you a code that help you to understand
java error stream, For this we have a class name'errorstreamexample'.Inside the
main method if we have the length of the argument is not equal to 1.The
System.err.println display an message as passed in the argument of it. The
most often used from class System are the standard output error and standard
error stream, these are the variable of System class.
System.err.println-This is Similar to System.out.println that is used to
print the result.
errorstreamexample.java
public class errorstreamexample {
public static void main(String[] args) {
if(args.length!=1){
System.err.println("usage: java.run.pathname");
return;
}
}
}
|
Output
Download code