Java Math.sin(double a)

Syntax

Math.sin(double a) has the following syntax.

public static double sin(double a)

Example

In the following code shows how to use Math.sin(double a) method.


//from w w  w .j a v  a  2s  .c om
public class Main {

   public static void main(String[] args) {

      double x = 45;
      double y = -180;

      // convert them to radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);

      // print the trigonometric sine for these doubles
      System.out.println("Math.sin(" + x + ")=" + Math.sin(x));
      System.out.println("Math.sin(" + y + ")=" + Math.sin(y));

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable