课程表

Groovy课程

工具箱
速查手册

Groovy xxxValue()方法

当前位置:免费教程 » Java相关 » Groovy

此方法接受Number作为参数,并基于调用的方法返回基本类型。 以下是可用的方法列表 -

  1. byte byteValue()
  2. short shortValue()
  3. int intValue()
  4. long longValue()
  5. float floatValue()
  6. double doubleValue()

参数 - 无需参数。

返回值 - 返回值是根据调用的值函数返回的原始类型。

例子

以下是方法值的用法示例。

  1. class Example {
  2. static void main(String[] args) {
  3. Integer x = 5;
  4. // Converting the number to double primitive type
  5. println(x.doubleValue());
  6. // Converting the number to byte primitive type
  7. println(x.byteValue());
  8. // Converting the number to float primitive type
  9. println(x.floatValue());
  10. // Converting the number to long primitive type
  11. println(x.longValue());
  12. // Converting the number to short primitive type
  13. println(x.shortValue());
  14. // Converting the number to int primitive type
  15. println(x.intValue());
  16. }
  17. }

当我们运行上面的程序,我们将得到以下结果 -

  1. 5.0
  2. 5
  3. 5.0
  4. 5
  5. 5
  6. 5
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号