My question is short. Are method preconditions and postconditions enforced by the compiler?

有帮助吗?

解决方案 2

Have a look at Contracts for Java, which helps enforing pre- and postconditions as well as invariants through annotations. But there's no compile-time-checking, only runtime as far as I know.

其他提示

No. Java doesn't have explicit support for design-by-contract pre/postconditions like (for instance) Ada does. See the java docs

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top