KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JAssert


1 public class JAssert {
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 }
10 class MyError extends Error JavaDoc {
11     MyError(String JavaDoc s) { super(s); }
12     static boolean throwError(String JavaDoc s) {
13         throw new MyError(s);
14     }
15 }
16
17
18
Popular Tags