• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i use assertions in java?

 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, i need to know what are Assertions and how they differ from exceptions,why do we need them? i really need help? my book doesnt help much.
Ammar
 
Jilesh Lakhani
Ranch Hand
Posts: 49
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/developer/technicalArticles/JavaLP/assertions/
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you use assert only for test if one line of your code is error or was config for false.
Assert not can to be use in place of IF. Assert is a good programming practice.
example:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic