1 public class JAssert { 2 3 public static void main(String [] 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 { 11 MyError(String s) { super(s); } 12 static boolean throwError(String s) { 13 throw new MyError(s); 14 } 15 } 16 17 18 | Popular Tags |