Javamso-Fareast-font-family:; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family:
Calibri; MSO-Hansi-theme-Font: minor-Latin "> NO cmso-Fareast-font-family:; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family:
Calibri; MSO-Hansi-theme-Font: minor-Latin "> the" Conditional compilation "feature in the language. This feature applies to cmso-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: calibri; MSO-Hansi-theme-Font: minor-Latin "> the language is used to solve cross-platform code problems, you can compile different parts of the code based on the specific platform on which the Code runs. Because javamso-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: calibri; MSO-Hansi-theme-Font: minor-Latin "> is designed as a cross-platform language, therefore, this feature is unnecessary.
MSO-ascii-font-family: calibri; MSO-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:
; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family: calibri;
MSO-Hansi-theme-Font: minor-Latin "> however, Conditional compilation is useful for code debugging. Like in cmso-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: calibri; MSO-Hansi-theme-Font: minor-Latin "> languages are the same, some Conditional compilation switches allow some debugging code to be used only during the development process, but not in the released version.
MSO-ascii-font-family: calibri; MSO-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:
; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family: calibri;
MSO-Hansi-theme-Font: minor-Latin "> we can use javamso-Fareast-font-family:; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family:
Calibri; MSO-Hansi-theme-Font: minor-Latin "> packagemso-Fareast-font-family:; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family:
Calibri; MSO-Hansi-theme-Font: minor-Latin "> to simulate the concept of Conditional compilation, it can be used for javamso-ascii-theme-Font: minor-Latin; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: calibri; MSO-Hansi-theme-Font: minor-Latin "> code debugging and development.
MSO-Fareast-font-family:; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family:
Calibri; MSO-Hansi-theme-Font: minor-Latin "> the code is as follows:
Code Package com. Vista. Debug
Public class assert
{
Private Static void printerr (string MSG)
{
System. Err. println (MSG );
}
Public final static void istrue (Boolean exp)
{
If (! Exp) printerr ("assertion failed ");
}
Public final static void isfalse (Boolean exp)
{
If (exp) printerr ("assertion failed ");
}
Public final static void istrue (Boolean exp, string MSG)
{
If (! Exp) printerr ("assertion failed" + MSG );
}
Public final static void isfalse (Boolean exp, string MSG)
{
If (! Exp) printerr ("assertion failed" + MSG );
}
}
MSO-ascii-font-family: verdana; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: verdana "> to use this asserted class for debugging in our code, you only need to introduce the following package:
Import com. Vista. Debug .*;
MSO-ascii-font-family: verdana; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: verdana "> when preparing to compile the release version, we need to clear the previously introduced asserted mechanism, for this reason, we only need to create a different package; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family: verdana "> Create a class named assert; MSO-Fareast-theme-Font: minor-Fareast; MSO-Hansi-font-family: verdana"> with the Code as follows:
Code Package com. Vista. Release
Public class assert
{
Private Static void printerr (string MSG ){}
Public final static void istrue (Boolean exp ){}
Public final static void isfalse (Boolean exp ){}
Public final static void istrue (Boolean exp, string MSG ){}
Public final static void isfalse (Boolean exp, string MSG ){}
}
MSO-ascii-font-family: verdana; MSO-Fareast-font-family:; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: verdana "> Import; MSO-ascii-font-family: verdana; MSO-Fareast-font-family: MSO; MSO-Fareast-theme-Font:
Minor-Fareast; MSO-Hansi-font-family: verdana "> the statement is modified as follows:
Import com. Vista. Release .*;
In this way, the asserted mechanism is removed from our code.