Language/JAVA

Java Assertion

nabaro 2016. 10. 11. 11:37

Java Assertion 은 Code 에서 설정하는 값을 검증 하기위해 사용하는 것이다.


Assertion 문법


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'Assertion 문법'
 
assert [boolean 식];
 
OR
 
assert [boolean 식] : [표현식];
 
'예제)'
 
assert num > 5;
 
assert num < 5 : "5보다 작은 값";
 
assert str.equals("");
 
assert !str.equals("");
 
assert str != null : "str에 null값이 들어있으면 안된다.";
 
cs





출처 : http://zion437.tistory.com/128


참고 : http://javacan.tistory.com/entry/79