Topic: assert 怎么用? |
Print this page |
1.assert 怎么用? | Copy to clipboard |
Posted by: ronnin Posted on: 2004-09-11 16:45 格式是 assert boolean statement : Message 吗? 我在Eclipse 3.0 里写 assert i>0 : "I below zero"; assert i>0; 等等 形式都通不过呢 ps: 我只用过Delphi的assert, 没想到Java连 assert 也这么专业; |
2.Re:assert 怎么用? [Re: ronnin] | Copy to clipboard |
Posted by: ronnin Posted on: 2004-09-11 16:49 http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html 我粗看了一下, E文不太好 好像是 Eclipse 设置的问题, 是不是要作什么特殊设置? |
3.Re:assert 怎么用? [Re: ronnin] | Copy to clipboard |
Posted by: 极品飞车 Posted on: 2004-09-12 15:44 (水平有限,译法仅供参考): An assertion is a statement in the JavaTM programming language that enables you to test your assumptions about your program. For example, if you write a method that calculates the speed of a particle, you might assert that the calculated speed is less than the speed of light. 断言在java语言程序中是一个语句,它使你能围绕你的程序测验你的假定. 譬如说,如果你写一个计算粒子速度的方法,你可以断言此已计算速度不如光速快.. Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system will throw an error. By verifying that the boolean expression is indeed true, the assertion confirms your assumptions about the behavior of your program, increasing your confidence that the program is free of errors. 每个断言包含一个你确信将会为实的布尔表达式.断言执行时,如果不为实,那么这系统将抛出一个错误.通过效验此布尔表达式的确为实,这断言确认你的假定是围绕你的程序行为,这样渐渐增强你的信心,此程序是没有错误可言的. Experience has shown that writing assertions while programming is one of the quickest and most effective ways to detect and correct bugs.以往经验已显示在写程序同时写断言是迅速和最有效察觉和校正臭虫的方式之一. Eclipse 设置,自己慢慢理解吧. preferences>java>Editor>code Assert |
4.Re:assert 怎么用? [Re: ronnin] | Copy to clipboard |
Posted by: freeport Posted on: 2004-09-13 14:20 ok |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |