This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| static void test() throws RuntimeException { | |
| try { | |
| System.out.print("test "); | |
| throw new RuntimeException(); | |
| } catch (Exception ex) { | |
| System.out.print("exception "); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| try { | |
| args = null; | |
| args[0] = "test"; | |
| System.out.println(args[0]); | |
| } catch (Exception ex) { | |
| System.out.println("Exception"); | |
| } catch (NullPointerException npe) { | |
| System.out.println("NullPointerException"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| Float pi = new Float(3.14f); | |
| if (pi > 3) { | |
| System.out.print("pi is bigger than 3. "); | |
| } | |
| else { | |
| System.out.print("pi is not bigger than 3. "); | |
| } | |
| finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| static void test() throws Error { | |
| if (true) | |
| throw new AssertionError(); | |
| System.out.print("test "); | |
| } | |
| public static void main(String[] args) { | |
| try { | |
| test(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A { | |
| public void process() { | |
| System.out.print("A,"); | |
| } | |
| } | |
| public class Test extends A { | |
| public void process() throws IOException { | |
| super.process(); | |
| System.out.print("B,"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //some code | |
| try { | |
| // some code here | |
| } catch (SomeException se) { | |
| // some code here | |
| } finally { | |
| // some code here | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try { | |
| ResourceConnection con = resourceFactory.getConnection(); | |
| Results r = con.query("GET INFO FROM CUSTOMER"); | |
| info = r.getData(); | |
| con.close(); | |
| } catch (ResourceException re) { | |
| errorLog.write(re.getMessage()); | |
| } | |
| return info; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void parse(String str) { | |
| try { | |
| float f = Float.parseFloat(str); | |
| } catch (NumberFormatException nfe) { | |
| f = 0; | |
| } finally { | |
| System.out.println(f); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GC { | |
| public static void main(String[] args) { | |
| GC e1 = new GC(); | |
| GC e2 = new GC(); | |
| GC e3 = new GC(); | |
| e3.e = e2; | |
| e1.e = e3; | |
| e2 = null; | |
| e3 = null; | |
| e2.e = e1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class GC { | |
| Short story = 5; | |
| GC go(GC cb) { | |
| cb = null; | |
| return cb; | |
| } | |
| public static void main(String[] args) { | |
| GC c1 = new GC(); |