0 votes
in JAVA by

   import java.util.Optional;  

    public class App {  

        public static void main(String[] args) {  

            String[] str = new String[10];        

            str[5] = null;;

            str[4] = "JAVA OPTIONAL CLASS EXAMPLE";

            Optional<String> checkNull = Optional.ofNullable(str[5]);  

            if(checkNull.isPresent()){  // It Checks, value is present or not  

                String lowercaseString = str[5].toLowerCase();  

                System.out.print(lowercaseString);  

            }else  

                System.out.println("String value is not present");  

        }  

    }  

Choose the correct output.

Compilation error

Runtime error: Null pointer Exception

Java optional example

String value is not present

Related questions

0 votes
asked Feb 6, 2020 in JavaScript by rajeshsharma
0 votes
asked Aug 30, 2022 in AWS by sharadyadav1986
...