OptionalIn this example, we created an Optional object containing the "Hello World" string and used the map method to get the length of the string. The map function takes a Function interface argument that defines how to transform the value in the Optional. The java.util Optional map method is part of the Java Standard Library's util package.optionalString = Optional.ofNullable("Hello World"); Optional optionalLength = optionalString.map(String::length); System.out.println(optionalLength.get()); // Outputs: 11