On Jul 17, 8:58 pm, Abbas Zaini <[email protected]> wrote:
> in an other word how if i want to count the number of times the letter 'a'
> occurred in the entries ( the two dimensional or even single dimensional
> array of String).
There are a number of ways to do this, but here is the simple one:
String myString = "Michèle";
char myChar = 'è';
int myCount = 0;
for (int i = 0; i < myString.length(); i++) {
if (myString.charAt(i) == myChar) {
myCount++;
}
}
System.out.println(myCount);
You may find benefit to study the String class before jumping into the
homework.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---