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