2014-08-04 18:53:56
0
I'm new at programming with languages. Can anyone explain why do I get that "this method must return a result type of String" issue? And what is the simplest code to achive my goal ? Also what is wrong with my coding?
The goal I want to achive in this method is to return a string if it includes "o" in the first index it should return "o" in the output, as an addition if it includes "z" at the second index of the string, method should return it as "z", if it includes them both, I mean the input string begins with "oz..." method should return a string as "oz".
public String startOz(String str)
{
if (str.length() <= 1)
return str;
else
if(str.substring(0, 1).equals("o"))
if (str.substring(1, 2).equals("z"))
return "oz";
else
return "o";
Thank You.