Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public int countYZ(String str) {
  2. int count = 0;
  3. int anfangsstelle = 0;
  4. String b = "";
  5. str = str.toLowerCase();
  6.  
  7. for (int i = 0; i < str.length(); i++) {
  8. if (Character.isLetter(str.charAt(i)) == false || i == str.length() - 1) {
  9. if (i == str.length() - 1) {
  10. b = str.substring(anfangsstelle);
  11. } else {
  12. if (anfangsstelle == i) {
  13. continue;
  14. }
  15. b = str.substring(anfangsstelle, i);
  16. }
  17. if (b.charAt(b.length() - 1) == 'z' || b.charAt(b.length() - 1) == 'y') {
  18. count++;
  19. anfangsstelle = i + 1;
  20. }
  21. }
  22. }
  23.  
  24. return count;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement