logo
  • 教程列表
  • SO官方文档
  • 断言
    • 用断言检查算术
  1. StackOverflow 文档
  2. Java Language 教程
  3. 断言
  4. 用断言检查算术

用断言检查算术

Created: November-22, 2018

a = 1 - Math.abs(1 - a % 2);

// This will throw an error if my arithmetic above is wrong.
assert a >= 0 && a <= 1 : "Calculated value of " + a + " is outside of expected bounds";

return a;
  • 断言

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明