KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > AssertTest2


1 public class AssertTest2 {
2
3     public static void main(String JavaDoc [] args){
4        int x = 0;
5        assert x == 0 : MyError.throwError("bug if error thrown");
6        assert x < 2 ? true : false : MyError.throwError("bug if error thrown");
7     }
8 }
9 class MyError extends Error JavaDoc {
10     MyError(String JavaDoc s) { super(s); }
11     static boolean throwError(String JavaDoc s) {
12         throw new MyError(s);
13     }
14 }
15
16
Popular Tags