Write code to cast To Char and return Optional<Character>
//package com.book2s; import java.util.Optional; public class Main { public static void main(String[] argv) { String text = "b"; System.out.println(castToChar(text)); }/*from ww w. ja v a 2 s .c o m*/ public static Optional<Character> castToChar(String text) { return (!looksLikeCharacter(text)) ? Optional.<Character> empty() : Optional.of(text.charAt(0)); } public static boolean looksLikeCharacter(String text) { return (text.length() == 1) ? true : false; } }