Java中等效的代码是: “`java assert false : “description”; “`

huangapple go评论79阅读模式
英文:

java equivalent of assert( 0 && "description")

问题

什么是Java中与此相当的内容?

assert(0 && "description");

我尝试过

assert(false && "description");

但是Java的类型对此要求太严格了。在断言语句中添加描述的惯用方式有什么提示吗?

英文:

What is the Java equivalent this?

assert(0 && "description");

I've tried

assert(false && "description");

But Java types are too strict for that. Any tips on the idiomatic way to add a description to an assert statement?

答案1

得分: 2

你可以使用以下方式为断言添加描述:

assert false : "description";

在https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html上有描述为:

assert Expression1 : Expression2 ;
英文:

You can add a description to an assertion using:

assert false : "description";

This is described as

assert Expression1 : Expression2 ;

on https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html

huangapple
  • 本文由 发表于 2020年7月23日 18:18:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/63051957.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定