×

Groovy 教程

Groovy 概述Groovy 环境Groovy 基本语法Groovy 数据类型Groovy 变量Groovy 运算符Groovy 循环Groovy 条件语句Groovy 方法Groovy 文件I/OGroovy 可选Groovy 数字Groovy 字符串Groovy 范围Groovy 列表Groovy 映射Groovy 日期和时间Groovy 正则表达式Groovy 异常处理Groovy 面向对象Groovy 泛型Groovy 特征Groovy 闭包Groovy 注释Groovy XMLGroovy JMXGroovy JSONGroovy DSLSGroovy 数据库Groovy 构建器Groovy 命令行Groovy 单元测试Groovy 模板引擎Groovy 元对象编程

Groovy xxxValue()方法


Groovy 数字Groovy 数字


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

byte byteValue() 
short shortValue() 
int intValue() 
long longValue() 
float floatValue() 
double doubleValue()

参数 - 无需参数。

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

例子

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

class Example { 
   static void main(String[] args) {  
      Integer x = 5; 
		
      // Converting the number to double primitive type
      println(x.doubleValue()); 
		
      // Converting the number to byte primitive type 
      println(x.byteValue()); 
		
      // Converting the number to float primitive type 
      println(x.floatValue());
		
      // Converting the number to long primitive type 
      println(x.longValue()); 
		
      // Converting the number to short primitive type 
      println(x.shortValue()); 
		
      // Converting the number to int primitive type 
      println(x.intValue());  
   } 
}

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

5.0 
5 
5.0 
5 
5 
5 

Groovy 数字Groovy 数字


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)