Focal length is the distance between the center of the mirror to the principal foci. In order to determine the focal length of a spherical mirror we should know the radius of curvature of that mirror. The distance from the vertex to the center of curvature is called radius of curvature.

The focal length is half the radius of curvature.

**Formula :**

F = ( R / 2 ) for concave mirror F = - ( R / 2 ) for convex mirror

Examples :

For a convex mirror Input : R = 30 Output : F = 15 For a convex mirror Input : R = 25 Output : F = - 12.5

`// Java program to determine ` `// the focal length of a ` `// of a spherical mirror ` `import` `java.util.*; ` `import` `java.lang.*; ` ` ` `public` `class` `GfG{ ` ` ` `// Determines focal length ` ` ` `// of a spherical concave ` ` ` `// mirror ` ` ` `public` `static` `float` `focal_length_concave(` `float` `R) ` ` ` `{ ` ` ` `return` `R / ` `2` `; ` ` ` `} ` ` ` ` ` `// Determines focal length of a ` ` ` `// spherical convex mirror ` ` ` `public` `static` `float` `focal_length_convex(` `float` `R) ` ` ` `{ ` ` ` `return` `- ( R / ` `2` `) ; ` ` ` `} ` ` ` ` ` `// Driver function ` ` ` `public` `static` `void` `main(String argc[]) ` ` ` `{ ` ` ` `float` `R = ` `30` `; ` ` ` ` ` `System.out.print(` `"Focal length of"` `+ ` ` ` `"spherical concave"` `+ ` ` ` `"mirror is : "` `+ ` ` ` `focal_length_concave(R) + ` ` ` `" units\n"` `); ` ` ` ` ` `System.out.println(` `"Focal length of"` `+ ` ` ` `"spherical convex"` `+ ` ` ` `"mirror is : "` `+ ` ` ` `focal_length_convex(R) + ` ` ` `" units"` `); ` ` ` `} ` `} ` ` ` `/* This code is contributed by Sagar Shukla */` |

*chevron_right*

*filter_none*

**Output:**

Focal length ofspherical concavemirror is : 15.0 units Focal length ofspherical convexmirror is : -15.0 units

Please refer complete article on Program to determine focal length of a spherical mirror for more details!

## Recommended Posts:

- Check if the given array is mirror-inverse
- Java Program for Number of jump required of given length to reach a point of form (d, 0) from origin in 2D plane
- Java program to print Even length words in a String
- Java Program to Generate N Number of Passwords of Length M Each
- Java Program for Program to calculate area of a Tetrahedron
- Java Program for Program to find area of a circle
- Java Program for Program for array rotation
- File length() method in Java with Examples
- Java Program to Extract Content from a Java's .class File
- Java Program to Implement Control Table in Java
- Length of the longest substring with consecutive characters
- Maximum length subarray with difference between adjacent elements as either 0 or 1
- Length of race track based on the final distance between participants
- Java Program for Selection Sort
- Java Program for Bubble Sort
- Java Program for Insertion Sort
- Java Program for Heap Sort
- Java Program for Radix Sort
- Java Program for n-th Fibonacci numbers
- Java Program for Counting Sort