Geeks Talk

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.

assert

This is a discussion on assert within the Java forums, part of the Software Development category; what are the uses of assert keyword?...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-24-2009
Contributing Member
 
Join Date: Aug 2009
Location: Indore
Posts: 33
Thanks: 9
Thanked 5 Times in 5 Posts
Sarje is on a distinguished road
assert

what are the uses of assert keyword?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-24-2009
Expert Member
 
Join Date: May 2009
Location: Bangalore
Posts: 1,195
Thanks: 155
Thanked 469 Times in 228 Posts
rijus is a glorious beacon of lightrijus is a glorious beacon of lightrijus is a glorious beacon of lightrijus is a glorious beacon of lightrijus is a glorious beacon of light
Re: assert

Quote:
Originally Posted by Sarje View Post
what are the uses of assert keyword?
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.
Reply With Quote
The Following 2 Users Say Thank You to rijus For This Useful Post:
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 11:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved