Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on assert within the Java forums, part of the Software Development category; what are the uses of assert keyword?...
|
|||||||
|
|||
|
Re: assert
Hi Sarje,
An assertion is a statement in the JavaTM programming language that enables you to test your assumptions about your program. For example, if you write a method that calculates the speed of a particle, you might assert that the calculated speed is less than the speed of light. The assertion statement has two forms. a) assert Expression1 ; b)assert Expression1 : Expression2 ; Expression1 is a boolean expression., Expression2 is an expression that has a value Use this version of the assert statement to provide a detail message for the AssertionError. The system passes the value of Expression2 to the appropriate AssertionError constructor, which uses the string representation of the value as the error's detail message. Thanks & Regards, Riju. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|