September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,8 +1,16 @@
|
|||
public static void main(String[] args){
|
||||
int a;
|
||||
//...input or change a here
|
||||
assert a == 42;//throws an AssertionError when a is not 42
|
||||
assert a == 42 : "Error message"; //throws an AssertionError
|
||||
//when a is not 42 with "Error message" for the message
|
||||
//the error message can be any non-void expression
|
||||
public class Assertions {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int a = 13;
|
||||
|
||||
// ... some real code here ...
|
||||
|
||||
assert a == 42;
|
||||
// Throws an AssertionError when a is not 42.
|
||||
|
||||
assert a == 42 : "Error message";
|
||||
// Throws an AssertionError when a is not 42,
|
||||
// with "Error message" for the message.
|
||||
// The error message can be any non-void expression.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue