Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2007, 10:14 PM
Registered User
 
Join Date: Sep 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default what is an assertion?

without trying to confuse me with million dollar words, can someone in plain english tell me why and what is an assertion and why we must or not use them
-enableassertions or -ea

 
Old September 28th, 2007, 12:09 PM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

An assertion is just a statement of something that should always be true. For example 1==1 ought always to be true, right? You mainly use assertions when you're developing or testing code. So, if you'd expect a variable to be equal to 5, you assert myVar==5; If it isn't equal to 5, the program will explode or the test will fail - letting you know that your expectation was wrong and the code was doing something different.

I hope that sort of answers your question.

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
 
Old September 28th, 2007, 01:03 PM
Registered User
 
Join Date: Sep 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you, I felt as if I was missing something

 
Old October 2nd, 2007, 06:54 PM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dinodynamo
Default

Although I use them often in my code, I didn't know what they were called, thanks for the question and the answer :) .

"Only the strong survive."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmer's assertion in getNextStepPos dishant XSLT 1 April 11th, 2008 09:48 AM
Debug assertion failure for wincore aparnakamath2000 Visual C++ 0 August 28th, 2007 05:49 AM
Debug assertion about m_pCtrlSite attaboyu Visual C++ 10 November 14th, 2005 01:53 PM
"Debug Assertion Failure" elleetan Visual C++ 3 September 20th, 2005 06:25 AM
Help in Assertion failure abdelkader Visual C++ 0 December 30th, 2003 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.