Hi,
I want to find the count of a specific letter by recursion.
Can you help me?
Thanks!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi,
I want to find the count of a specific letter by recursion.
Can you help me?
Thanks!
lets say you have a string name NAME and you wanted to count numbers of 'a' in it.
You should try
int count = 0; //to count the numbers of appearance of letter
for(int i = 0; i < NAME.length(); i++) //NAME.length() is a command to count length of characters in a string.
{
if(NAME.charAt(i) == 'a')
count++;
}
print(number of a in NAME is count)
This should help you
vlkn448
a piece of cake.
you run java Recur vulkan443 4 you'll get the result 2 letter(s) 4...
Last edited by copeg; July 15th, 2012 at 09:26 AM.
@voodoo, lets not do other peoples homework for them. Your code has been removed as per the forum rules. Please read:
http://www.javaprogrammingforums.com...n-feeding.html
OKAY, sorry!
I found! Here is my function
public static int finEs(String kelime){ if(kelime.equals("")){ return 0; }else{ int k = 0; if(kelime.substring(0, 1).equals("e")){ k++; } return k + eBul(kelime.substring(1)); }