Was there something more to that line, hard to tell what context this statement was being used in? The word 'invariant' means unchangable, something that is constant.
When faced with an easy thing to do and a hard thing to do, always pick the right thing to do!<p><a href="http://yadav.shorturl.com" target="_blank" rel="nofollow">Rajinder Yadav</a>
Joined: Apr 13, 2003
Hi Rajinder Thanks Rajinder for the prompt reply. Sorry for the incomplete question. The question was asking about when should an assert statement be used. So we can say that final vars. and Strings are invariant.
An invariant is a rule that applies throughout the life of a data structure or procedure, and all changes must maintain the correctness of the invariant. Say you have a program which is simulating some card game. You know that each pack of cards must have 13 cards of each suit, and that the suits are spades, hearts, diamonds and clubs. So, it is appropriate to use assertions which test the above, eg there cannot be more than 13 cards of the spade suit.