I have tried the following methods:
Optional[] arr1 = new Optional[0]; // Warning: Raw use of parameterized class 'Optional'
Optional<Integer>[] arr2 = new Optional[0]; // Warning: Unchecked assignment: 'java.util.Optional[]' to 'java.util.Optional<java.lang.Integer>[]'
Optional<Integer>[] arr3 = new Optional<Integer>[0]; // Error: Generic array creation
What is the problem with each different initialization above?
What would be the correct initialization method, enabling type resolution and safety in future access to the array?
Java 8