0
Can you change the error output of a code
code playground
5 Answers
+ 32
What code?
+ 10
Post your code here.
+ 4
If it is compile error then no. If runtime error then yes
+ 2
where's your code ?
+ 1
In Java, yes. Using the try/catch block (below), you can execute another set of code (example: an output message) if one set fails (Exception handling). Like @Eligijus Sikartas said, this only works for a runtime error. A compiling error cannot be changed.
public class JError{
public static void main(String[] args){
try{
File file=new File(C:\Photos\NonExistentImage.png);
}
catch (Exception e){
System.out.println("Error! File not found!");
}
}
}