Assert ÔÚJavaºÍGroovyÖеÄÇø±ð
¶ÔÓÚ·ÀÓùÐÔ±à³Ì¶øÑÔ£¬assertÒ»Ö±¶¼ÊǷdz£ÖØÒªµÄ¹¤¾ß¡£µ«¶ÔÓÚÊìϤ-ea²ÎÊýµÄJava³ÌÐòÔ±¶øÑÔ£¬µ±ËûÃÇ¿´µ½ËùÓÐGroovy¶ÏÑÔÎÞÂÛÊÇ·ñÓÐ-ea¶¼ÕÕÑùÖ´ÐÐʱһ¶¨»á·Ç³£À§»ó¡£
ÊÂʵÉÏ£¬GroovyµÄ¶ÏÑÔÊÇÎÞÌõ¼þ¿ªÆôµÄ£¡
¶Ô´Ë£¬¿ª·¢ÈËÔ±Roshan Dawrani×öÁËÈçϽâÊÍ£º£¨ÔÎÄ£©
The JDK documentation has a long chapter on assertions that talks about the disabling feature for assertions and its impact on compiling, starting the VM, and resulting design issues. Although this is fine and the design rationale behind Java assertions is clear, we feel the disabling feature is the
biggest stumbling block for using assertions in Java. You can never be sure that your assertions are really executed.
ÔÚCore Java£¨»òÕßÊÇTIJ£¿¼Ç²»ÇåÁË£©À×÷ÕßÌáµ½assertionÀàËÆ“ÔÚº£±ß¿ªÈüͧҪ´øºÃÄãµÄ¿¨Í¨¾ÈÉúȦ£»Èç¹û´¬ÒѾÔÚ´óº£ÖÐÑ룬¾Í°Ñ¾ÈÉúȦÈÓµôºÃÁË”¡£²»¹ý£¬ÔÚGroovyÖУ¬ÏÔÈ»ÕâÖÖ·ÀÓù´ëÊ©»áÒ»Ö±¸úËæÄãµ½´óº£µÄÈÎÒâ½ÇÂ䣨ϣÍû²»ÊǺ£µ×£©¡£
PS£ºÈç¹û×Ðϸ¿´¿´Groovy¶ÏÑÔµÄÊä³ö£¬ÄãÒ»¶¨»áÒâʶµ½Ëü¶ÔÓÚdebugÊǶàôÓÐÓãº
1: def xml = new XmlParser().parseText("x")
2: assert "y" == xml.text()
3: -----
4: output:
5:
6: assert "y" == xml.text()
7: | | |
8: | | x
9: | test[attributes={}; value=[x]]
10: false
11:
******
Quote of the day:
I didn't really say everything I said. - Yogi Berra
Ïà¹ØÎĵµ£º
“Éϵ۸³ÓèÈËÀà˵»°µÄÄÜÁ¦£¬¶øÑÔÓïÓÖ´´ÔìÁË˼Ï룬˼ÏëÊÇÈËÀà¶ÔÓîÖæµÄÁ¿¶È¡£”
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡——Õª×Ô¡¶Prometheus Unbound¡·£¬Shelley
? ÈËÀà……¼«ÆäÊÜÄÇЩÒѾ³ÉΪÉç»á±í´ï¹¤¾ßµÄÌض¨ÓïÑÔµÄÖ§Åä¡£ÏëÏñһϣ¬Èç¹ûÒ»¸öÈË¿ÉÒÔ²»Ê¹ÓÃÓïÑÔ¾ÍÄܹ»´Ó±¾ÖÊÉÏÊÊÓ¦ÏÖÊµÊ ......
ÈýµÀJAVA»ù´¡Ìâ
ÌâÄ¿(1)
class A {
public int i = 10;
}
class B extends A{
public int i = 20;
}
public class Test{
public static void main(String&nbs ......
1£®1 ÃæÏò¶ÔÏóµÄ»ù±¾¸ÅÄî
¡¡¡¡ÃæÏò¶ÔÏóµÄ»ù±¾Ë¼Ïë
¡¡¡¡ÃæÏò¶ÔÏóÊÇÒ»ÖÖÐÂÐ˵ijÌÐòÉè¼Æ·½·¨,»òÕßÊÇÒ»ÖÖеijÌÐòÉè¼Æ¹æ·¶(paradigm),Æä»ù±¾Ë¼ÏëÊÇʹÓöÔÏó¡¢Àà¡¢¼Ì³Ð¡¢·â×°¡¢ÏûÏ¢µÈ»ù±¾¸ÅÄîÀ´½øÐÐ
³ÌÐòÉè¼Æ¡£´ÓÏÖʵÊÀ½çÖп͹۴æÔÚµÄÊÂÎ¼´¶ÔÏ󣩳ö·¢À´¹¹ÔìÈí¼þϵͳ£¬²¢ÇÒÔÚϵͳ¹¹ÔìÖо¡¿ÉÄÜÔËÓÃÈËÀàµÄ×ÔȻ˼ά·½Ê½¡£¿ª·¢ ......
Ò» DOM ÒÔÏ´úÂëÓÃDOMÊÇÉú³ÉÒ»¸öXMLÎĵµ
package xml;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
imp ......
package bag;
import java.util.*;
public class Dou {
/*
* Éú³ÉÆË¿ËÅÆ
*/
public String[] puke() {
String[] s1 = { "ºÚÌÒ", "ºìÌÒ", "÷»¨", "·½Æ¬" };
String[] s2 = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J",
  ......