Java .sin()

Yash-Var's avatar
Published Dec 17, 2022
Contribute to Docs

The Math.sin() method returns the trigonometric sine of an angle argument, given in radians.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

Syntax

Math.sin(angle)

The angle parameter is expressed in radians.

  • The result is in the range [-1, 1].
  • If the angle is NaN or infinity, NaN is returned.

Example

The following example demonstrates the application of .sin() method:

// Check.java
public class Check {
public static void main(String args[]) {
// convert degrees to radians
double pi = Math.PI;
double degree = 60;
double radian = degree * pi/180;
System.out.println( "Sine of 60 degrees is " + Math.sin(radian));
}
}

This results in the following output:

Sine of 60 degrees is 0.866025

All contributors

Contribute to Docs

Learn Java on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours