Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int countYZ(String str) {
- int count = 0;
- int anfangsstelle = 0;
- String b = "";
- str = str.toLowerCase();
- for (int i = 0; i < str.length(); i++) {
- if (Character.isLetter(str.charAt(i)) == false || i == str.length() - 1) {
- if (i == str.length() - 1) {
- b = str.substring(anfangsstelle);
- } else {
- if (anfangsstelle == i) {
- continue;
- }
- b = str.substring(anfangsstelle, i);
- }
- if (b.charAt(b.length() - 1) == 'z' || b.charAt(b.length() - 1) == 'y') {
- count++;
- anfangsstelle = i + 1;
- }
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement