One of my favorite examples is the main method with try/catch.
For example: http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
public static void main(String args[]) { try{ FileInputStream fstream = ... }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } }
This try/catch is absolutely NOT NEEDED! If you skip them, the JVM does absolutely the same work. :)
<blockquote>
More information about formatting options
If you listen to your code, it'll tell you what you need.
— Kent Beck (probably)
↑ Grab this Headline Animator
try/catch in main
One of my favorite examples is the main method with try/catch.
For example:
http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
public static void main(String args[]) {
try{
FileInputStream fstream = ...
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
This try/catch is absolutely NOT NEEDED! If you skip them, the JVM does absolutely the same work. :)