0
public static <T> Optional<T> of(<T> value) {
    return new Optional<> value 
}

Is first <T> related to the Optional<T>? How to understand what first <T> and Optional<T> is doing?

  • 1
    See https://stackoverflow.com/questions/23454952/uses-for-optional, and https://stackoverflow.com/questions/20746429/limit-a-stream-by-a-predicate. If you try to find the first element of a stream but there are no elements - what is the result nothing or the first element - hence optional. – Mr R Mar 18 '21 at 07:08
  • 5
    See [Generic Methods](https://docs.oracle.com/javase/tutorial/java/generics/methods.html) in the Java tutorial. – Federico klez Culloca Mar 18 '21 at 07:13

0 Answers0