Calculate the arc length of an angle in Java

In this tutorial, we will see how to calculate the arc length for a given angle in Java.

Mathematically, arc length is calculated as follows:

The length of an arc is equal to the circumference of the circle(2* π*r), times the fraction of the circle represented by the arc’s measure. Since a circle has a total angle of 360°. Therefore, on dividing an arc’s degree measure by it, we will be able to find the fraction of the circumference of the circle that the arc makes up. Hence, if we multiply the circumference by this fraction of the degree measure of an arc to the total angle, then we get the length of the arc.


Arc length  = (Θ ÷ 360) * (2 * π * radius)


A = (Θ ÷ 360) * (diameter * π)

where, Θ  is the degree measure of arc.

Java Code:

public class prog { 
    public static void main(String args[])throws IOException { 
        BufferedReader ob=new BufferedReader(new InputStreamReader(;
        System.out.println("Radius : ");
        double radius = Double.parseDouble(ob.readLine()); 
        System.out.println("Angle : ");
        double angle = Double.parseDouble(ob.readLine()); 
        double arc_length;
        if (angle > 360) { 
            System.out.println("Invalid angle"); 
        else { 
            arc_length = (2*Math.PI * radius) * (angle / 360.0);
            System.out.println("Arc length : "+arc_length); 

We will prompt the user to enter the values of radius and degree measure of the arc whose length is to be calculated. For that, we will use the BufferedReader class to take the user input.

After creating an object of BufferedReader class, we will use the ob.readLine() method to read the value as a string and then parse it into a double type since radius and angle will be floating-point numbers.

  • If the user enters the value of the angle more than 360, we will not proceed with the calculation.

Using these values, we can now calculate the arc length.
We have used the mathematical formula for our calculation.

Finally, we display the value.


Radius : 4
Angle: 30
Arc Length : 2.0943

So we are successfully able to calculate the arc length of an angle in Java programming language. I hope you have understood our program for this task.

Also read,

Calculating Area of a Trapezoid using Java

Calculating the area of a parallelogram in Java


Leave a Reply

Your email address will not be published. Required fields are marked *