You can use assertions to detect errors that may otherwise go unnoticed.您可以使用斷言來偵測錯誤,否則可能被遺漏的地方。 Assertions contain Boolean expressions that define the correct state of your program at specific points in the program source code.斷言包含布爾表達式,界定正確的狀態,您的程序在特定的點,在該計劃中的源代碼。 The designers of the Java platform, however, didn’t include support for assertions.設計者在Java平台上,不過,並不包括支持的斷言。 Perhaps they viewed exceptions as a superior feature, allowing you to use try/catch/finally to throw an exception instead of aborting the program as in assertions.也許他們認為,作為一個例外優勢功能,讓您使用嘗試/趕上/最後拋出一個例外而不是中止計劃在斷言。 But the Java 2 Platform, Standard Edition (J2SE) release 1.4, has introduced a built-in assertion facility.但Java 2平台標準版( J2SE )發布1.4 ,推出了內置在斷言設施。 This article does the following:本文以下內容:

* Presents an overview of design by contract *介紹概述了設計合同
* Presents an overview of assertions *介紹概述了斷言
* Shows how to roll your own assertion capabilities *說明如何輥自己的斷言能力
* Describes the new assertion facility *介紹了新的斷言設施
* Shows how to use the new assertion facility *說明如何使用新的斷言設施
* Offers guidelines for using assertions *提供指引,使用斷言
* Presents examples of how to use assertions *介紹的例子,如何使用斷言

Read the閱讀 article here文章在這裡 ; highly recommended. ;強烈建議。