成都创新互联网站制作重庆分公司

AssertinC#&Java-创新互联

Assert是什么?

断言(Assertion)是一种调试程序的方式。AssertinC#&J
ava

C#中的Assert

In a debug compilation, Assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
If you compile in Release, all Debug.Assert's are automatically left out.

创新互联服务紧随时代发展步伐,进行技术革新和技术进步,经过十多年的发展和积累,已经汇集了一批资深网站策划师、设计师、专业的网站实施团队以及高素质售后服务人员,并且完全形成了一套成熟的业务流程,能够完全依照客户要求对网站进行做网站、成都做网站、建设、维护、更新和改版,实现客户网站对外宣传展示的首要目的,并为客户企业品牌互联网化提供全面的解决方案。

ref: https://stackoverflow.com/questions/163538/c-sharp-what-does-the-assert-method-do-is-it-still-useful

Java中的Assert

Assertions (by way of the assert keyword) were added in Java 1.4. They are used to verify the correctness of an invariant in the code.

code

 public static void main(String[] args) {
      String name = null;
      assert (name != null) : "name is null, maybe a bug";
      System.out.println(name);
   }

JVM start args

"vmArgs":"-ea" //enable assertions

result

Exception in thread "main" java.lang.AssertionError: name is null, maybe a bug
        at App.main(App.java:7)

ref:https://stackoverflow.com/questions/2758224/what-does-the-java-assert-keyword-do-and-when-should-it-be-used


新闻标题:AssertinC#&Java-创新互联
本文地址:http://cxhlcq.com/article/iphis.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部