hi
im trying to check if two strings are equal but ignoring the vowels so that "hello" can equal "hallo" or even "hll". i have a recursive defination for looking at the vowels but i cant get it to work for ignoring the vowels. at the moment i get an error message saying there is no return statement but all my "if"s have "else"s to ensure a return statement
class equalsCalc
{
boolean equals( String strA, String strB )
{
if ( strA.length() == 0 && strB.length() == 0 )
return true;
else if ( strA.length() == 0 && strB.length() != 0 )
return false;
else if ( strA.length() != 0 && strB.length() == 0 )
return false;
else if ( strA.charAt(0) != strB.charAt(0) )
{
char [] vowels = new char [5];
vowels[0] = 'a';
vowels[1] = 'e';
vowels[2] = 'i';
vowels[3] = 'o';
vowels[4] = 'u';
for(int j = 0; j<vowels.length; j++)
{
if (strA.charAt(0)!= vowels[j])
return false;
else if (strB.charAt(0) != vowels[j])
return false;
else
return equals(strA.substring(1), strB.substring(1));
}
}
else
return equals( strA.substring(1), strB.substring(1) );
}
}
public class equalsTester
{
public static void main(String[]args)
{
equalsCalc e = new equalsCalc();
boolean result = e.equals("hello","hallo");
System.out.println(result);
}
}