Reputation: 405
I need to print the statement in the assertion to the console when condition is true in eclipse. How?
public static void main(String[] args) {
try {
assert(args[0].equals("x")): "kate";
} catch(Error e) {
System.out.print("ae ");
} finally {
try {
assert(args[0].equals("y")): "jane";
} catch(Exception e2) {
System.out.print("ae2 ");
}
}
}
Upvotes: 4
Views: 3099
Reputation: 95948
You need to:
Now, when you have something like:
assert(1==2) : "Error!!!";
You'll see in the console:
Exception in thread "main" java.lang.AssertionError: Error!!!
at .....
Upvotes: 6