×

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 sin()方法


Groovy 数字Groovy 数字


该方法返回指定double值的正弦值。

句法

double sin(double d)

参数

d - 双数据类型。

返回值

此方法返回指定double值的正弦值。

例子

下面是一个使用这个方法的例子 -

class Example { 
   static void main(String[] args) { 
      double degrees = 45.0; 
      double radians = Math.toRadians(degrees);
	  
      System.out.format("The value of pi is %.4f%n", Math.PI);
      System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians));
   }
}

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

The value of pi is 3.1416 
The sine of 45.0 degrees is 0.7071

Groovy 数字Groovy 数字


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)