资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

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://cdkjz.cn/article/iphis.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220