Check out example codes for "area of octagon in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.Scanner;
public class AreaOfOctagon
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter length of side of octagon: ");
      int side = sc.nextInt();
      float area = (float) (2 * (1 + Math.sqrt(2)) * side * side);
      System.out.println("Area of octagon is: " + area);
      sc.close();
   }
}

Learn ReactJs, React Native from akashmittal.com