Results 1 to 1 of 1
Thread: help with exercise - recursion
- 07-14-2014, 09:06 AM #1Member
- Join Date
- Jul 2014
- Rep Power
help with exercise - recursion
i'm learning with myProgrammingLab.
the question is:
Write a recursive, boolean -valued method , containsVowel, that accepts a string and returns true if the string contains a vowel.
A string contains a vowel if: •The first character of the string is a vowel, or
•The rest of the string (beyond the first character ) contains a vowel
i wrote the answer in all kind of variation and checked with blueJ and my code works.
in the exercise website i get an error and i don't understand what is wrong.
my code is:
public static boolean containVowel(String str)
if(str.length() <= 0)
if(str.charAt(str.length()-1) == 'a' || str.charAt(0)=='e' || str.charAt(0)=='i' || str.charAt(0)=='o' || str.charAt(0)=='u')
the error i get is:
⇒ You almost certainly should be using: containsVowel
⇒ We think you might want to consider using: =
⇒ We think you might want to consider using: <
please anyone can shade some light?
- By alsade in forum New To JavaReplies: 6Last Post: 03-27-2014, 12:31 PM
- By Honijahu in forum New To JavaReplies: 5Last Post: 03-19-2013, 11:30 AM
- By ccie007 in forum New To JavaReplies: 7Last Post: 09-28-2010, 05:54 PM
- By OptimusPrime in forum New To JavaReplies: 2Last Post: 12-28-2009, 06:26 PM
- By Feldom in forum New To JavaReplies: 1Last Post: 10-28-2007, 04:48 PM