title: Object cannot be converted to string when using Optional class in Java
body: <p>I have the following code trying to use the Optional class:</p>
  
  <pre><code>import java.util.Optional;
  
  // one class needs to have a main() method
  public class HelloWorld
  {
    public String orelesMethod() {
      return "hello";
    }
  
    public void test() {
      String value;
      value = Optional.ofNullable(null).orElse(orelesMethod());
      System.out.println(value); 
    }
  
    // arguments are passed using the text field below this editor
    public static void main(String[] args)
    {
      HelloWorld hello = new HelloWorld();
  
      hello.test();
    }
  }
  </code></pre>
  
  <p>when compiling it, it says:</p>
  
  <pre><code>incompatible types: Object cannot be converted to String
      value = Optional.ofNullable(null).orElse(orelesMethod());
  </code></pre>
  
  <p>I can not find it out what is the problem, can anyone help on it?</p>
  
  <p>Thank you!</p>