Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. `try
  2. {
  3. String s = " LITTLE RABBIT";
  4. s.toUpperCase();
  5. int l = s.length();
  6. int a =0;
  7. char ch1, ch2;
  8. for( int i =0; i < l; i++)
  9. {
  10. ch1 = s.charAt(i);
  11. ch2 = s.charAt(i+1);
  12. if( ch1 == ch2)
  13. {
  14. a++;
  15. }
  16. }
  17. System.out.println(a);
  18. }
  19. catch(StringIndexOutOfBoundsException e)
  20. {
  21. System.out.println(e);
  22. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement