1 /*2 differences between compile-time exceptions and run-time exceptions3 Compile-time exception : the Java program must show processing, or the program will have an error that cannot be compiled4 Run -time exception: No display processing is required, and can be treated as a compile-time exception5 */6 Importjava.text.ParseException;7 ImportJava.text.SimpleDateFormat;8 Importjava.util.Date;9 Public classExceptiondemo {Ten Public Static voidMain (string[] args) { One //int a = ten; A //int b = 0; - //if (b! = 0) { - //System.out.println (A/b); the // } - -String s = "2014-11-20"; - //SimpleDateFormat sdf = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); +SimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd"); - //Date d = sdf.parse (s); + Try { ADate d =Sdf.parse (s); at System.out.println (d); -}Catch(ParseException e) { - //e.printstacktrace (); -SYSTEM.OUT.PRINTLN ("Resolution date has gone wrong"); - } - } in}
Differences between Java 19-4 compile-time exceptions and run-time exceptions