code: public static double length3D(Polygon polygon) {
          double length = 0.0;
          length += length3D(polygon.getExteriorRing().getCoordinateSequence());
          for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
              length += length3D(polygon.getInteriorRingN(i));
          }
          return length;
      }
docs: Returns the 3D perimeter of the given polygon.
  
  @param polygon Polygon
  @return The 3D perimeter of the given polygon